Skip to content

Feature: refactor/db-timestamptz to dev - #621

Merged
aamoghS merged 3 commits into
devfrom
refactor/db-timestamptz
Nov 15, 2026
Merged

aamoghS merged 3 commits into
devfrom
refactor/db-timestamptz

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Automated PR tracking changes from refactor/db-timestamptz into dev.


Note

High Risk
Wide schema type change plus auth token expiry handling; requires a successful migrate push and affects time-sensitive check-in and verification flows.

Overview
Moves the database layer to timezone-aware timestamps (timestamptz) so app Date values, SQL now(), and stored instants stay aligned regardless of the Postgres session time zone.

Every Drizzle timestamp column across packages/db/src/schemas now declares { withTimezone: true }. Auth raw SQL casts verification-token expires as ::timestamptz, and hackathon bulk check-in stops using now() at time zone 'utc' in favor of plain now() / updated comments in points.ts for the same reason.

check-drift.mts now fails if live columns are still timestamp without time zone when the schema expects with time zone, catching pushes that did not actually alter column types.

Reviewed by Cursor Bugbot for commit 66cd0c5. Bugbot is set up for automated code reviews on this repo. Configure here.

All 156 timestamp columns were timestamp without time zone. They held UTC wall
time only because production sessions run in GMT and drizzle writes
toISOString(); a session in another zone, or raw SQL comparing them with
now(), would read them hours off. Declare them withTimezone, as status_sample
already was. push converts each with SET DATA TYPE, which casts through the
session zone (GMT in production), so every stored instant is kept.

The one raw write that worked around the old type (now() at time zone 'utc'
in admin/status.ts) is now plain now(). Rehearsed on a PGX copy: 156
conversions, no prompt, sampled instants unchanged, full suite passes.
@github-actions
github-actions Bot requested a review from aamoghS as a code owner November 14, 2026 23:48
@aamoghS
aamoghS marked this pull request as draft November 14, 2026 23:48
@aamoghS aamoghS closed this Nov 14, 2026
@aamoghS aamoghS reopened this Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor Author

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Visit the preview URL for this PR (updated for commit 66cd0c5):

https://hacklyticss2026--pr-621-z59orv6a.web.app

(expires Sun, 22 Nov 2026 00:00:10 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 5d238be33273095766c18a8339b7b0c47de8a950

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Visit the preview URL for this PR (updated for commit 66cd0c5):

https://hacklytics2027--pr-621-u1di3r1u.web.app

(expires Sun, 22 Nov 2026 00:00:11 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: c48ba34db61581e25fe2978355160b5eefe0e83f

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 66ca30c. Configure here.

Comment thread packages/db/src/schemas/auth.ts Resolved
@aamoghS
aamoghS marked this pull request as ready for review November 14, 2026 23:52
The verification-token SQL cast its ISO instants with ::timestamp, which drops
the Z and lets the session TimeZone reinterpret the wall time once
verificationToken.expires stores a zone. In a non-UTC session that shifts
code expiry and the once-a-minute send gate by hours. ::timestamptz keeps the
instant.
db:check only confirmed that declared columns exist, so a push that skipped a
type change (timestamp to timestamptz) left the old type and still passed,
and the build shipped code expecting the new one. It now compares every
timestamp column's time zone with the declaration and fails the build on a
mismatch, which keeps the running revision in place.
@aamoghS
aamoghS merged commit e1d778f into dev Nov 15, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant