[PR #5823] fix: treat generateId "serial" as numeric ID and correct UUID column types across adapters #14500

Closed
opened 2026-04-13 09:30:28 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/5823

State: closed
Merged: Yes


  • Several areas where useNumberId is used but we didn't check generateId === "serial".
  • Kysely get-migration with useUUID was generating incorrect field type for mssql & mysql.
  • Fixed warnings with getMigration where uuid type wasn't recognized during second round of migrations.
  • Added uuid support to Drizzle & Prisma
  • Added uuid test suite

Summary by cubic

Treat generateId: "serial" as numeric IDs across the stack, and fix UUID handling and column types in migrations and generators, including DB-native UUID defaults where supported.

  • Bug Fixes

    • Treat generateId: "serial" the same as useNumberId across adapters, schema generators (Drizzle/Prisma), telemetry, and tests.
    • Correct UUID types and defaults in Kysely migrations and Drizzle/Prisma: MySQL/MSSQL use varchar(36) (including foreign keys); Postgres uuid with pg_catalog.gen_random_uuid (Drizzle) and Prisma @db.Uuid with default(dbgenerated("pg_catalog.gen_random_uuid()")) and FK columns as @db.Uuid; SQLite text.
    • Add supportsUUIDs to adapters and ID transform logic (input/output) to respect DB-native UUID generation; only generate UUIDs in JavaScript when the DB cannot.
    • Fix Kysely migration warnings by recognizing uuid types on subsequent runs, and ensure proper casting when referencing id with numeric IDs.
  • Migration

    • If you previously generated MySQL/MSSQL schemas with generateId: "uuid", regenerate migrations/schemas to apply the corrected types.

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

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/5823 **State:** closed **Merged:** Yes --- - Several areas where `useNumberId` is used but we didn't check `generateId === "serial"`. - Kysely get-migration with `useUUID` was generating incorrect field type for `mssql` & `mysql`. - Fixed warnings with `getMigration` where `uuid` type wasn't recognized during second round of migrations. - Added `uuid` support to Drizzle & Prisma - Added `uuid` test suite <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Treat generateId: "serial" as numeric IDs across the stack, and fix UUID handling and column types in migrations and generators, including DB-native UUID defaults where supported. - **Bug Fixes** - Treat generateId: "serial" the same as useNumberId across adapters, schema generators (Drizzle/Prisma), telemetry, and tests. - Correct UUID types and defaults in Kysely migrations and Drizzle/Prisma: MySQL/MSSQL use varchar(36) (including foreign keys); Postgres uuid with pg_catalog.gen_random_uuid (Drizzle) and Prisma @db.Uuid with default(dbgenerated("pg_catalog.gen_random_uuid()")) and FK columns as @db.Uuid; SQLite text. - Add supportsUUIDs to adapters and ID transform logic (input/output) to respect DB-native UUID generation; only generate UUIDs in JavaScript when the DB cannot. - Fix Kysely migration warnings by recognizing uuid types on subsequent runs, and ensure proper casting when referencing id with numeric IDs. - **Migration** - If you previously generated MySQL/MSSQL schemas with generateId: "uuid", regenerate migrations/schemas to apply the corrected types. <sup>Written for commit d3376bc7084ea0c6ba38761ab4b210426d66a6e3. Summary will update automatically on new commits.</sup> <!-- End of auto-generated description by cubic. -->
GiteaMirror added the pull-request label 2026-04-13 09:30:28 -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#14500