[PR #3475] [CLOSED] Fix/postgres timestampz #21744

Closed
opened 2026-04-15 20:34:19 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3475
Author: @JuanPabloGilA
Created: 7/19/2025
Status: Closed

Base: mainHead: fix/postgres-timestampz


📝 Commits (2)

  • a4f0462 fix(drizzle-generator): use timestamp with time zone for PostgreSQL
  • a371415 fix(drizzle-generator): use timestamp with time zone for PostgreSQL

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 packages/cli/src/generators/drizzle.ts (+1 -1)

📄 Description

What does this PR do?

Fixes a bug where PostgreSQL schemas were being generated with timestamp (without timezone), causing expiration checks to break due to timezone mismatches between the database and the server.


Why is it needed?

When using BetterAuth with PostgreSQL, fields like expires_at for verification tokens or password resets were being generated with timestamp (without time zone). This causes tokens to be considered expired immediately if the server and database are not in the same timezone (e.g., UTC vs local time).

By using timestamp(..., { withTimezone: true }), the expiration logic becomes reliable across environments and timezones.


Changes

  • Changed Drizzle schema generator for PostgreSQL to use timestamp(..., { withTimezone: true }) instead of the default timestamp.
  • Fixes alignment with Drizzle’s expected timestamp with time zone behavior.

Closes #3461


Summary by cubic

Fixed a bug where PostgreSQL schemas used timestamps without time zone, causing token expiration checks to fail when server and database time zones differed.

  • Bug Fixes
  • Updated the Drizzle schema generator to use timestamp(..., { withTimezone: true }) for PostgreSQL date fields.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/3475 **Author:** [@JuanPabloGilA](https://github.com/JuanPabloGilA) **Created:** 7/19/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/postgres-timestampz` --- ### 📝 Commits (2) - [`a4f0462`](https://github.com/better-auth/better-auth/commit/a4f0462efd4521f1b4ca498fd42986ce45ff89a6) fix(drizzle-generator): use timestamp with time zone for PostgreSQL - [`a371415`](https://github.com/better-auth/better-auth/commit/a371415c1f74b724d6478724bb15edce6d4eec22) fix(drizzle-generator): use timestamp with time zone for PostgreSQL ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/generators/drizzle.ts` (+1 -1) </details> ### 📄 Description ### What does this PR do? Fixes a bug where PostgreSQL schemas were being generated with `timestamp` (without timezone), causing expiration checks to break due to timezone mismatches between the database and the server. --- ### Why is it needed? When using BetterAuth with PostgreSQL, fields like `expires_at` for verification tokens or password resets were being generated with `timestamp` (without time zone). This causes tokens to be considered expired immediately if the server and database are not in the same timezone (e.g., UTC vs local time). By using `timestamp(..., { withTimezone: true })`, the expiration logic becomes reliable across environments and timezones. --- ### Changes - Changed Drizzle schema generator for PostgreSQL to use `timestamp(..., { withTimezone: true })` instead of the default `timestamp`. - Fixes alignment with Drizzle’s expected `timestamp with time zone` behavior. --- Closes [#3461](https://github.com/better-auth/better-auth/issues/3461) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixed a bug where PostgreSQL schemas used timestamps without time zone, causing token expiration checks to fail when server and database time zones differed. - **Bug Fixes** - Updated the Drizzle schema generator to use `timestamp(..., { withTimezone: true })` for PostgreSQL date fields. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 20:34:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#21744