[PR #4622] [MERGED] fix(cli): timestamp in schema for Drizzle with SQLite #5490

Closed
opened 2026-03-13 12:24:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4622
Author: @zy1p
Created: 9/13/2025
Status: Merged
Merged: 9/30/2025
Merged by: @himself65

Base: canaryHead: patch-1


📝 Commits (1)

  • 79f84cd fix(cli): losing sqlite timestamp precision

📊 Changes

5 files changed (+76 additions, -76 deletions)

View changed files

📝 packages/cli/src/generators/drizzle.ts (+2 -2)
📝 packages/cli/test/__snapshots__/auth-schema-sqlite-number-id.txt (+18 -18)
📝 packages/cli/test/__snapshots__/auth-schema-sqlite-passkey-number-id.txt (+19 -19)
📝 packages/cli/test/__snapshots__/auth-schema-sqlite-passkey.txt (+19 -19)
📝 packages/cli/test/__snapshots__/auth-schema-sqlite.txt (+18 -18)

📄 Description

fix: https://github.com/better-auth/better-auth/pull/4889

.defaultNow() which is (cast((julianday('now') - 2440587.5)*86400000 as integer)) was storing timestamp in subsecond precision.

refers to implementation, retrieving timestamp will get wrong result.

using (current_timestamp) was storing text into integer field, use (cast(unixepoch('subsecond') * 1000 as integer) instead. see https://github.com/drizzle-team/drizzle-orm/issues/2810

image image image

🔄 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/4622 **Author:** [@zy1p](https://github.com/zy1p) **Created:** 9/13/2025 **Status:** ✅ Merged **Merged:** 9/30/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`79f84cd`](https://github.com/better-auth/better-auth/commit/79f84cdf5fe523a5e62d01f499fdd42b7f5ef366) fix(cli): losing sqlite timestamp precision ### 📊 Changes **5 files changed** (+76 additions, -76 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/generators/drizzle.ts` (+2 -2) 📝 `packages/cli/test/__snapshots__/auth-schema-sqlite-number-id.txt` (+18 -18) 📝 `packages/cli/test/__snapshots__/auth-schema-sqlite-passkey-number-id.txt` (+19 -19) 📝 `packages/cli/test/__snapshots__/auth-schema-sqlite-passkey.txt` (+19 -19) 📝 `packages/cli/test/__snapshots__/auth-schema-sqlite.txt` (+18 -18) </details> ### 📄 Description fix: https://github.com/better-auth/better-auth/pull/4889 `.defaultNow()` which is `(cast((julianday('now') - 2440587.5)*86400000 as integer))` was storing timestamp in subsecond precision. refers to [implementation](https://github.com/drizzle-team/drizzle-orm/blob/8e8a9e902410ed2068a015d59180b225045dddf1/drizzle-orm/src/sqlite-core/columns/integer.ts#L136), retrieving timestamp will get wrong result. using `(current_timestamp)` was storing text into integer field, use `(cast(unixepoch('subsecond') * 1000 as integer)` instead. see https://github.com/drizzle-team/drizzle-orm/issues/2810 <img width="683" height="386" alt="image" src="https://github.com/user-attachments/assets/52ec221d-b36e-4664-afac-d3e43676ae80" /> <img width="838" height="114" alt="image" src="https://github.com/user-attachments/assets/9d9cb278-7048-4d50-8401-f464f77d7138" /> <img width="460" height="442" alt="image" src="https://github.com/user-attachments/assets/754d3a3e-9510-4ca3-ac3e-ae2d65008100" /> --- <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-03-13 12:24:46 -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#5490