Give every model created/modified timestamps

TimeStampedModel goes on UUIDModel, so all 28 domain models get row birthdays in
one place. Without them the dashboard can only ever describe the present: "42
members" is knowable, "members joined this month" is not, and no metric can show
direction.

Order dropped its own created/modified -- redeclaring a field from an abstract
base is an error, and its column survives as a plain AlterField (verbose_name
only), so no order data moves.

Note for reading early charts: auto_now_add backfills existing rows with a single
migration timestamp, so everything that predates this commit shares one birthday
and will show up as a spike at that instant rather than as real history.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 00:53:12 +02:00
parent 1dd2e5099f
commit 9127be0c42
15 changed files with 423 additions and 13 deletions

View File

@@ -68,8 +68,19 @@ class TenantQuerySet(models.QuerySet):
return self.filter(club=require_current_club())
class UUIDModel(models.Model):
"""Abstract base class giving every model a UUID primary key"""
class TimeStampedModel(models.Model):
"""Row birthdays. Without these, every metric can only describe the present —
"42 members" is knowable, "members joined this month" is not."""
created = models.DateTimeField(_("created"), auto_now_add=True)
modified = models.DateTimeField(_("modified"), auto_now=True)
class Meta:
abstract = True
class UUIDModel(TimeStampedModel):
"""Abstract base class giving every model a UUID primary key and timestamps."""
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)