[PR #5661] [CLOSED] fix(cli): use 64 bit ints for numeric IDs for mysql/mssql #31748

Closed
opened 2026-04-17 22:38:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5661
Author: @ping-maxwell
Created: 10/29/2025
Status: Closed

Base: canaryHead: fix/kysely-generator-id-use-64bit


📝 Commits (6)

  • 0cc2b90 fix(cli): use 64 bit ints for numeric IDs for mysql/mssql
  • 6b8711a chore: lint
  • 3998ca9 update: drizzle & prisma should use bigInt for numeric IDs
  • 3590da5 fix: kysely fk use bigint
  • 20d9c0d chore: lint
  • c76fcf3 fix: drizzle with bigint should pass mode

📊 Changes

8 files changed (+67 additions, -43 deletions)

View changed files

📝 packages/better-auth/src/adapters/adapter-factory/index.ts (+5 -4)
📝 packages/better-auth/src/db/get-migration.ts (+7 -5)
📝 packages/cli/src/generators/drizzle.ts (+9 -3)
📝 packages/cli/src/generators/prisma.ts (+10 -5)
📝 packages/cli/test/__snapshots__/auth-schema-mysql-number-id.txt (+9 -9)
📝 packages/cli/test/__snapshots__/auth-schema-mysql-passkey-number-id.txt (+9 -8)
📝 packages/cli/test/__snapshots__/schema-numberid.prisma (+8 -8)
📝 packages/core/src/db/adapter/index.ts (+10 -1)

📄 Description

closes https://github.com/better-auth/better-auth/issues/5657

Should generate 64bit for ids with useNumberId. We don't do this for mysql & mssql on kysely, Prisma & Drizzle. This PR resolves such for the CLI generator & handles IDs as BigInt in the adapter factory.


Summary by cubic

Switch numeric IDs to 64-bit (BIGINT) for MySQL and MSSQL when useNumberId is enabled, and handle IDs as BigInt throughout the adapter. This prevents truncation and keeps the CLI generator and runtime consistent.

  • Bug Fixes

    • Generate BIGINT columns for numeric IDs in MySQL/MSSQL migrations.
    • Convert ID values to BigInt in the adapter factory for reads/writes.
    • Allow BigInt and BigInt[] in query Where values.
  • Migration

    • If you previously created INTEGER ID columns on MySQL/MSSQL with useNumberId, alter them to BIGINT.
    • Update application code to use BigInt for IDs (not Number), including query filters and payloads.

🔄 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/5661 **Author:** [@ping-maxwell](https://github.com/ping-maxwell) **Created:** 10/29/2025 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `fix/kysely-generator-id-use-64bit` --- ### 📝 Commits (6) - [`0cc2b90`](https://github.com/better-auth/better-auth/commit/0cc2b9044a3461c22b45efb15802d82615eb8f9f) fix(cli): use 64 bit ints for numeric IDs for mysql/mssql - [`6b8711a`](https://github.com/better-auth/better-auth/commit/6b8711a9687ab07e43baf4713b23ed5a2a682611) chore: lint - [`3998ca9`](https://github.com/better-auth/better-auth/commit/3998ca9cd3f6a5e688e608572109c7e72d24ad55) update: drizzle & prisma should use bigInt for numeric IDs - [`3590da5`](https://github.com/better-auth/better-auth/commit/3590da5026c3bd1a0336739a650356acfb9f4659) fix: kysely fk use bigint - [`20d9c0d`](https://github.com/better-auth/better-auth/commit/20d9c0da575caa47d0e6c0efb3c6713853c729b3) chore: lint - [`c76fcf3`](https://github.com/better-auth/better-auth/commit/c76fcf38625e19de162a7af969105d57c5c7b14a) fix: drizzle with bigint should pass `mode` ### 📊 Changes **8 files changed** (+67 additions, -43 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/adapter-factory/index.ts` (+5 -4) 📝 `packages/better-auth/src/db/get-migration.ts` (+7 -5) 📝 `packages/cli/src/generators/drizzle.ts` (+9 -3) 📝 `packages/cli/src/generators/prisma.ts` (+10 -5) 📝 `packages/cli/test/__snapshots__/auth-schema-mysql-number-id.txt` (+9 -9) 📝 `packages/cli/test/__snapshots__/auth-schema-mysql-passkey-number-id.txt` (+9 -8) 📝 `packages/cli/test/__snapshots__/schema-numberid.prisma` (+8 -8) 📝 `packages/core/src/db/adapter/index.ts` (+10 -1) </details> ### 📄 Description closes https://github.com/better-auth/better-auth/issues/5657 Should generate 64bit for ids with `useNumberId`. We don't do this for mysql & mssql on kysely, Prisma & Drizzle. This PR resolves such for the CLI generator & handles IDs as `BigInt` in the adapter factory. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Switch numeric IDs to 64-bit (BIGINT) for MySQL and MSSQL when useNumberId is enabled, and handle IDs as BigInt throughout the adapter. This prevents truncation and keeps the CLI generator and runtime consistent. - **Bug Fixes** - Generate BIGINT columns for numeric IDs in MySQL/MSSQL migrations. - Convert ID values to BigInt in the adapter factory for reads/writes. - Allow BigInt and BigInt[] in query Where values. - **Migration** - If you previously created INTEGER ID columns on MySQL/MSSQL with useNumberId, alter them to BIGINT. - Update application code to use BigInt for IDs (not Number), including query filters and payloads. <!-- 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-17 22:38:01 -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#31748