Make create_date and update_date time-zone-aware on all tables #24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
create_dateandupdate_dateon every table areTIMESTAMPwithout a time zone. They come fromAbstractEntity(@CreateDateColumn,@UpdateDateColumn), where TypeORM's default column type for PostgreSQL is zone-less. Every explicitly declared time column in the backend isTIMESTAMP WITH TIME ZONE(ticked_at,added_at, the session and passkeyexpires_at, anditems_changed_atfrom spec 002).Why it matters
A zone-less timestamp stores only the wall-clock reading. Its meaning depends on configuration:
now()/CURRENT_TIMESTAMPin its session time zone, and Node reads the value back as its own local time. If the two zones differ, every value is off by a fixed number of hours. The repo sets no explicit time zone for either.These values reach clients as
createdAt/updatedAt.Proposal
AbstractEntityastimestamp with time zone.ALTER COLUMN ... TYPE TIMESTAMP WITH TIME ZONE USING ... AT TIME ZONE '<zone>').Found
During the repo architecture step for spec 002 (shopping list overview previews), whose backfill has to read these zone-less columns. Out of scope for 002.
araemer referenced this issue2026-10-03 14:07:30 +00:00
One more finding for this issue, from the spec 002 repo architect:
AbstractDtoEntityMapper.toEntitycopiescreatedAt/updatedAtfrom the DTO onto the entity. For domains that go throughsave(), it was not verified whether TypeORM then writes those Node-side values intocreate_date/update_date. If it does, those rows carry values written in the Node process's zone instead of the database session's zone, and the conversion in the migration would have to account for that.The shopping list tables are not affected: there, both columns are only written by the database (
DEFAULT now()and TypeORM's appendedupdate_date = CURRENT_TIMESTAMP).The session zone itself is not set anywhere in the repo. It comes from the PostgreSQL server's
TimeZonesetting in the Puppet configuration;SHOW TimeZone;on stage and production shows it.