timestamps
File: schema/mixins/timestamps.yaml
Adds created_at / updated_at and the trigger that maintains them — the
actor-free subset of audit. Use on
tables that want creation/update times but carry no change-attribution (no
created_by / updated_by, so no dependency on an identity table).
No parameters.
Columns
Section titled “Columns”| Column | Type | Null | Notes |
|---|---|---|---|
created_at | timestamptz | NOT NULL | stamped on INSERT |
updated_at | timestamptz | NOT NULL | refreshed on every write |
Trigger
Section titled “Trigger”10_timestamps_stamp(BEFORE INSERT/UPDATE) — stampscreated_aton INSERT andupdated_aton every write. Seetimestamps_stamp.
Why a trigger, not column defaults
Section titled “Why a trigger, not column defaults”Maintenance is trigger-based, not column defaults. A BEFORE trigger has to
fire anyway to keep updated_at fresh on UPDATE (a DEFAULT only fires on
INSERT), so created_at is stamped in the same trigger at no extra cost — and
can’t be overridden by a client-supplied value. Both are set to the same
CURRENT_TIMESTAMP (transaction start) on INSERT.
# tables that want times but no actor attributionmixins: [timestamps]Pair with audit instead when you need
actor columns.