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:
48
apps/client/models/folders.py
Normal file
48
apps/client/models/folders.py
Normal file
@@ -0,0 +1,48 @@
|
||||
from django.db import models
|
||||
|
||||
from core.models.base import UUIDPrimaryKeyModel
|
||||
|
||||
|
||||
class ClientFavoriteFolder(UUIDPrimaryKeyModel):
|
||||
staff = models.ForeignKey(
|
||||
"org.Staff", on_delete=models.CASCADE, related_name="favorite_folders"
|
||||
)
|
||||
name = models.CharField(max_length=10)
|
||||
is_default = models.BooleanField(default=False)
|
||||
sort_order = models.IntegerField(default=0)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
deleted_at = models.DateTimeField(null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "client_favorite_folders"
|
||||
indexes = [
|
||||
models.Index(fields=["staff"], name="idx_cff_staff"),
|
||||
]
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["staff"],
|
||||
condition=models.Q(is_default=True, deleted_at__isnull=True),
|
||||
name="uq_cff_default_per_staff",
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class ClientFolderItem(models.Model):
|
||||
folder = models.ForeignKey(
|
||||
ClientFavoriteFolder, on_delete=models.CASCADE, related_name="items"
|
||||
)
|
||||
client = models.ForeignKey(
|
||||
"fonrey_client.Client", on_delete=models.CASCADE, related_name="folder_items"
|
||||
)
|
||||
added_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "client_folder_items"
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["folder", "client"], name="uq_cfi_folder_client"
|
||||
),
|
||||
]
|
||||
indexes = [
|
||||
models.Index(fields=["client"], name="idx_cfi_client"),
|
||||
]
|
||||
Reference in New Issue
Block a user