[PR #6366] [CLOSED] Fix: mysql date generating #6620

Closed
opened 2026-03-13 13:05:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6366
Author: @MarkForLoop
Created: 11/27/2025
Status: Closed

Base: canaryHead: fix/mysql-date-generate


📝 Commits (10+)

📊 Changes

117 files changed (+4527 additions, -1487 deletions)

View changed files

📝 .github/workflows/adapter-tests.yml (+1 -1)
📝 .github/workflows/ci.yml (+1 -1)
📝 demo/nextjs/.env.example (+2 -1)
📝 demo/nextjs/components/sign-in.tsx (+22 -0)
📝 demo/nextjs/lib/auth.ts (+4 -0)
📝 demo/nextjs/tsconfig.json (+1 -0)
📝 demo/nextjs/turbo.json (+3 -1)
📝 docs/app/blog/[[...slug]]/page.tsx (+9 -4)
📝 docs/app/changelogs/[[...slug]]/page.tsx (+7 -4)
📝 docs/app/community/_components/header.tsx (+3 -2)
📝 docs/app/community/_components/stats.tsx (+27 -1)
📝 docs/app/community/page.tsx (+39 -2)
📝 docs/app/global.css (+1 -0)
📝 docs/components/builder/social-provider.tsx (+15 -0)
docs/components/contributors.tsx (+34 -0)
📝 docs/components/floating-ai-search.tsx (+19 -0)
📝 docs/components/mobile-search-icon.tsx (+1 -1)
📝 docs/components/nav-bar.tsx (+1 -1)
📝 docs/components/nav-mobile.tsx (+2 -2)
📝 docs/components/sidebar-content.tsx (+17 -11)

...and 80 more files

📄 Description

https://dev.mysql.com/doc/refman/9.4/en/datetime.html
MySQL date fields generated as timestamp instead of datetime

DATETIME

  • Format: YYYY-MM-DD hh:mm:ss
  • Range: '1000-01-01 00:00:00' → '9999-12-31 23:59:59'

TIMESTAMP

  • Range: '1970-01-01 00:00:01' UTC → '2038-01-19 03:14:07' UTC

Because timestamp has a far more limited valid range, this causes issues for users who need broader date support. The schema generator should default to datetime() instead of timestamp() for MySQL date fields.


Summary by cubic

Fix MySQL date/time generation to use datetime with fsp: 3, proper CURRENT_TIMESTAMP(3) defaults, and correct .$onUpdate behavior. This produces valid schemas with millisecond precision and correct imports.

  • Bug Fixes
    • Generate datetime(...) for MySQL date fields instead of timestamp.
    • Use default(sqlCURRENT_TIMESTAMP(3)) and ensure .$onUpdate works for MySQL dates (sets CURRENT_TIMESTAMP(3) when using onUpdate(new Date())).
    • Update imports to include datetime and sql for MySQL.
    • Harden cookie parsing in multi-session and OIDC consent to avoid false values.

Written for commit e833fa27b4. Summary will update automatically on new commits.


🔄 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/6366 **Author:** [@MarkForLoop](https://github.com/MarkForLoop) **Created:** 11/27/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/mysql-date-generate` --- ### 📝 Commits (10+) - [`bff00f6`](https://github.com/better-auth/better-auth/commit/bff00f6b7fb3d95363888186cd610ea3e4e0f174) chore: release v1.4.0 - [`e2c474f`](https://github.com/better-auth/better-auth/commit/e2c474f58cb803b36765200bf59d7743cc205d59) chore: update 1.4 og image - [`555e092`](https://github.com/better-auth/better-auth/commit/555e09235839dbe1f243ccbfeeaed1d0f6e6b7cc) commit - [`a1f05b1`](https://github.com/better-auth/better-auth/commit/a1f05b16894b4a8868ce3c8d3d39f25df6c6e47f) chore: lint - [`2f3577c`](https://github.com/better-auth/better-auth/commit/2f3577c55600b525727d64b54b7cf13cbd0bc9a7) docs: fix responsivness for changelog images - [`29564df`](https://github.com/better-auth/better-auth/commit/29564df59f89c1bc7c0aa43b82f8de5d40406480) chore: fix typo - [`9e2b5ce`](https://github.com/better-auth/better-auth/commit/9e2b5ce6322e3a36d6a191772fa47389027f5b4e) chore: fix typo - [`44308bf`](https://github.com/better-auth/better-auth/commit/44308bf20d431bd943a92a2ed4204a6b7d5a4182) feat(api-key): support secondary storage (#6014) - [`69c756a`](https://github.com/better-auth/better-auth/commit/69c756a4101edf805e82f0cd5841a9dbb594c750) chore(docs): fix invalid 1.4 blog links (#6191) - [`6aca409`](https://github.com/better-auth/better-auth/commit/6aca4094280322f7dff2057d1993c38470c3b124) fix(jwt): retrieve latest keys from storage properly (#6208) ### 📊 Changes **117 files changed** (+4527 additions, -1487 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/adapter-tests.yml` (+1 -1) 📝 `.github/workflows/ci.yml` (+1 -1) 📝 `demo/nextjs/.env.example` (+2 -1) 📝 `demo/nextjs/components/sign-in.tsx` (+22 -0) 📝 `demo/nextjs/lib/auth.ts` (+4 -0) 📝 `demo/nextjs/tsconfig.json` (+1 -0) 📝 `demo/nextjs/turbo.json` (+3 -1) 📝 `docs/app/blog/[[...slug]]/page.tsx` (+9 -4) 📝 `docs/app/changelogs/[[...slug]]/page.tsx` (+7 -4) 📝 `docs/app/community/_components/header.tsx` (+3 -2) 📝 `docs/app/community/_components/stats.tsx` (+27 -1) 📝 `docs/app/community/page.tsx` (+39 -2) 📝 `docs/app/global.css` (+1 -0) 📝 `docs/components/builder/social-provider.tsx` (+15 -0) ➕ `docs/components/contributors.tsx` (+34 -0) 📝 `docs/components/floating-ai-search.tsx` (+19 -0) 📝 `docs/components/mobile-search-icon.tsx` (+1 -1) 📝 `docs/components/nav-bar.tsx` (+1 -1) 📝 `docs/components/nav-mobile.tsx` (+2 -2) 📝 `docs/components/sidebar-content.tsx` (+17 -11) _...and 80 more files_ </details> ### 📄 Description https://dev.mysql.com/doc/refman/9.4/en/datetime.html MySQL date fields generated as `timestamp` instead of `datetime` DATETIME - Format: YYYY-MM-DD hh:mm:ss - Range: '1000-01-01 00:00:00' → '9999-12-31 23:59:59' TIMESTAMP - Range: '1970-01-01 00:00:01' UTC → '2038-01-19 03:14:07' UTC Because `timestamp` has a far more limited valid range, this causes issues for users who need broader date support. The schema generator should default to `datetime()` instead of `timestamp()` for MySQL date fields. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix MySQL date/time generation to use datetime with fsp: 3, proper CURRENT_TIMESTAMP(3) defaults, and correct .$onUpdate behavior. This produces valid schemas with millisecond precision and correct imports. - **Bug Fixes** - Generate datetime(...) for MySQL date fields instead of timestamp. - Use default(sql`CURRENT_TIMESTAMP(3)`) and ensure .$onUpdate works for MySQL dates (sets CURRENT_TIMESTAMP(3) when using onUpdate(new Date())). - Update imports to include datetime and sql for MySQL. - Harden cookie parsing in multi-session and OIDC consent to avoid false values. <sup>Written for commit e833fa27b4e63c8c82e520234f57b796fa02c7a1. Summary will update automatically on new commits.</sup> <!-- 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-03-13 13:05:50 -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#6620