feat(client,setting): complete Phase 2 with partitioned client_follow_logs
- apps/client (11 models): Client, ClientContact, ClientRequirement, ClientSchoolPreference, ClientFollowLog (partitioned), ClientFollowLogAttachment, ClientViewing, ClientPropertyMatch, ClientStatusLog, ClientFavoriteFolder, ClientFolderItem - apps/client/0002 RunSQL: PARTITION BY RANGE(created_at) for client_follow_logs + monthly partitions + default; triggers update_client_last_follow + update_client_viewing_progress; partial unique index on client_no WHERE deleted_at IS NULL - apps/setting (4 models): LookupGroup, LookupItem, TenantSetting, FieldRequirementRule (tenant schema only per spec) manage.py check green; all 9 Phase 2 apps complete.
This commit is contained in:
55
apps/client/models/follow.py
Normal file
55
apps/client/models/follow.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from django.db import models
|
||||
|
||||
from core.enums import ClientFollowLogType
|
||||
from core.models.base import UUIDPrimaryKeyModel
|
||||
|
||||
|
||||
class ClientFollowLog(models.Model):
|
||||
"""Partitioned table (PARTITION BY RANGE created_at).
|
||||
|
||||
Managed via RunSQL; Django ORM treats parent as unmanaged.
|
||||
"""
|
||||
|
||||
id = models.UUIDField(primary_key=True)
|
||||
created_at = models.DateTimeField()
|
||||
client = models.ForeignKey(
|
||||
"fonrey_client.Client",
|
||||
on_delete=models.CASCADE,
|
||||
related_name="follow_logs",
|
||||
)
|
||||
|
||||
log_type = models.CharField(max_length=30, choices=ClientFollowLogType.choices)
|
||||
purpose = models.CharField(max_length=50, blank=True, default="")
|
||||
content = models.TextField(blank=True, default="")
|
||||
log_tag = models.CharField(max_length=50, blank=True, default="")
|
||||
change_detail = models.JSONField(null=True, blank=True)
|
||||
|
||||
is_public = models.BooleanField(default=True)
|
||||
is_deletable = models.BooleanField(default=True)
|
||||
|
||||
operator = models.ForeignKey(
|
||||
"org.Staff", null=True, blank=True, on_delete=models.SET_NULL
|
||||
)
|
||||
operator_snapshot = models.JSONField(null=True, blank=True)
|
||||
|
||||
deleted_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "client_follow_logs"
|
||||
managed = False
|
||||
unique_together = (("id", "created_at"),)
|
||||
|
||||
|
||||
class ClientFollowLogAttachment(UUIDPrimaryKeyModel):
|
||||
follow_log_id = models.UUIDField() # cross-partitioned FK; not enforced via Django FK
|
||||
file_key = models.TextField()
|
||||
file_name = models.CharField(max_length=255)
|
||||
file_size = models.IntegerField()
|
||||
file_type = models.CharField(max_length=10, blank=True, default="")
|
||||
has_location = models.BooleanField(default=False)
|
||||
sort_order = models.SmallIntegerField(default=0)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "client_follow_log_attachments"
|
||||
indexes = [models.Index(fields=["follow_log_id"], name="idx_cfla_log")]
|
||||
Reference in New Issue
Block a user