fix(timestamps) Store create and update times as timestamp with time zone #37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "timestamptz-create-update-date"
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?
Fixes #24.
What
1792886400000-ConvertCreateUpdateDateToTimestamptz: convertscreate_dateandupdate_dateon the 16 zone-lessAbstractEntitytables, plususer_passkey_challenge.created_at, toTIMESTAMP WITH TIME ZONE. Existing values are interpreted as UTC (AT TIME ZONE 'UTC', spelled out rather thancurrent_setting('TimeZone')). Stage and production have always run in UTC, so no stored value moves.recipe_image,ai_recipe_import_loganduser_sessionwere already time-zone-aware.down()reverses the conversion.AbstractEntity,AiRecipeImportLogEntity,UserSessionEntityandPasskeyChallengeEntitydeclaretimestamp with time zone.AppDataSourceand the integration data source connect with-c timezone=UTC(DB_SESSION_TIME_ZONEinsrc/utils/dateUtils.ts).mapBaseDtoToEntityno longer copies the client'screatedAt/updatedAtonto the entity. TypeORM 0.3.27 writes those values on insert, and on update whenever they differ from the stored row, so clients could set their own timestamps (written in Node's zone). Update paths reload the entity after saving, so responses still carry both values.docs/adr/2026-10-25-utc-time-zone-aware-timestamps.md,docs/architecture.md.No wire-format change; no contract or recipe-app change.
⚠️ Deployment order
This must be released to production before the database server's
TimeZoneis moved to Europe/Berlin. Rows written after the move but before this migration would hold Berlin wall-clock readings and be shifted by the conversion. After the migration, the server zone only affects howpsqldisplays values.On a local development database whose zone is Europe/Berlin, the migration shifts existing dev values by 1–2 hours. That's harmless.
Verification
npm run build: passesnpm test: 57 files, 622 tests passingnpm run test:integration: 45 tests passing (runs every migration, including the new one, into a fresh schema)'2026-10-24 18:00'→2026-10-24 20:00+02→'2026-10-24 18:00'🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.