[PR #3873] [MERGED] Use defaultNow() for drizzle timestamp fields #21960

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/3873
Author: @Badbird5907
Created: 8/8/2025
Status: Merged
Merged: 9/3/2025
Merged by: @himself65

Base: canaryHead: canary


📝 Commits (4)

  • 8875dd4 feat(cli): use .defaultNow() for drizzle timestamp fields with new Date() default
  • 2838d81 fix(cli): lint drizzle generator
  • d838aba Merge branch 'canary' into Badbird5907/canary
  • d597b50 fix: test

📊 Changes

7 files changed (+44 additions, -69 deletions)

View changed files

📝 packages/cli/src/generators/drizzle.ts (+8 -1)
📝 packages/cli/test/__snapshots__/auth-schema-mysql-number-id.txt (+6 -14)
📝 packages/cli/test/__snapshots__/auth-schema-mysql.txt (+6 -14)
📝 packages/cli/test/__snapshots__/auth-schema-number-id.txt (+6 -14)
📝 packages/cli/test/__snapshots__/auth-schema-sqlite-number-id.txt (+6 -6)
📝 packages/cli/test/__snapshots__/auth-schema-sqlite.txt (+6 -6)
📝 packages/cli/test/__snapshots__/auth-schema.txt (+6 -14)

📄 Description

This PR modifies the Drizzle schema generator to use .defaultNow() instead of .defaultFn(() => new Date()) for timestamp fields that are defaulted to the current date.

I haven't been able to test this on a real project, however I have modified the tests with the expected results, and everything looks ok.


Summary by cubic

Updated the Drizzle schema generator to use .defaultNow() for timestamp fields instead of .defaultFn(() => new Date()), making default values clearer and more consistent.


🔄 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/3873 **Author:** [@Badbird5907](https://github.com/Badbird5907) **Created:** 8/8/2025 **Status:** ✅ Merged **Merged:** 9/3/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `canary` --- ### 📝 Commits (4) - [`8875dd4`](https://github.com/better-auth/better-auth/commit/8875dd427d72a228442fc14582639053de5cf8af) feat(cli): use .defaultNow() for drizzle timestamp fields with new Date() default - [`2838d81`](https://github.com/better-auth/better-auth/commit/2838d819542a0d8f1f6f10f598a3b6337de76319) fix(cli): lint drizzle generator - [`d838aba`](https://github.com/better-auth/better-auth/commit/d838aba84be6af5fb30c815cc8134fbf37ff034e) Merge branch 'canary' into Badbird5907/canary - [`d597b50`](https://github.com/better-auth/better-auth/commit/d597b50348fc7f4e955fa75286872e7ab2676254) fix: test ### 📊 Changes **7 files changed** (+44 additions, -69 deletions) <details> <summary>View changed files</summary> 📝 `packages/cli/src/generators/drizzle.ts` (+8 -1) 📝 `packages/cli/test/__snapshots__/auth-schema-mysql-number-id.txt` (+6 -14) 📝 `packages/cli/test/__snapshots__/auth-schema-mysql.txt` (+6 -14) 📝 `packages/cli/test/__snapshots__/auth-schema-number-id.txt` (+6 -14) 📝 `packages/cli/test/__snapshots__/auth-schema-sqlite-number-id.txt` (+6 -6) 📝 `packages/cli/test/__snapshots__/auth-schema-sqlite.txt` (+6 -6) 📝 `packages/cli/test/__snapshots__/auth-schema.txt` (+6 -14) </details> ### 📄 Description This PR modifies the Drizzle schema generator to use `.defaultNow()` instead of `.defaultFn(() => new Date())` for timestamp fields that are defaulted to the current date. I haven't been able to test this on a real project, however I have modified the tests with the expected results, and everything looks ok. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Updated the Drizzle schema generator to use .defaultNow() for timestamp fields instead of .defaultFn(() => new Date()), making default values clearer and more consistent. <!-- 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:43:17 -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#21960