[PR #5809] [MERGED] feat: add support for uuids #23141

Closed
opened 2026-04-15 21:30:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5809
Author: @Bekacru
Created: 11/6/2025
Status: Merged
Merged: 11/7/2025
Merged by: @Bekacru

Base: canaryHead: fix/migrations


📝 Commits (7)

📊 Changes

10 files changed (+195 additions, -61 deletions)

View changed files

📝 docs/content/docs/guides/create-a-db-adapter.mdx (+1 -5)
📝 docs/content/docs/reference/options.mdx (+2 -4)
📝 packages/better-auth/src/adapters/adapter-factory/index.ts (+13 -11)
📝 packages/better-auth/src/adapters/adapter-factory/test/adapter-factory.test.ts (+38 -0)
📝 packages/better-auth/src/db/get-migration-schema.test.ts (+56 -2)
📝 packages/better-auth/src/db/get-migration.ts (+53 -34)
📝 packages/cli/package.json (+2 -0)
packages/cli/test/__snapshots__/migrations-uuid.sql (+7 -0)
📝 packages/core/src/types/init-options.ts (+14 -2)
📝 pnpm-lock.yaml (+9 -3)

📄 Description

Summary by cubic

Add first-class UUID support for IDs and standardize ID generation via advanced.database.generateId. Deprecates useNumberId and updates migrations/adapter logic to handle "uuid" and "serial" across Postgres, MySQL, and MSSQL.

  • New Features

    • generateId now accepts "uuid" and "serial".
    • Migrations create UUID columns and defaults:
      • Postgres: uuid type with default gen_random_uuid().
      • MySQL/MSSQL: uuid type with default uuid().
    • Validation updated: requesting numeric IDs ("serial"/useNumberId) throws if the adapter doesn’t support them.
    • Deprecation warning added for useNumberId; prefer generateId: "serial".
  • Migration

    • Replace useNumberId with generateId: "serial".
    • To enable UUIDs, set generateId: "uuid".
    • Postgres requires the pgcrypto extension for gen_random_uuid().

Written for commit cc50d5f28f. 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/5809 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 11/6/2025 **Status:** ✅ Merged **Merged:** 11/7/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix/migrations` --- ### 📝 Commits (7) - [`b8aea8f`](https://github.com/better-auth/better-auth/commit/b8aea8f7ddbe1443e5dfc6a6b92e466df7e83484) feat: add support uuids - [`3bf14f9`](https://github.com/better-auth/better-auth/commit/3bf14f9157d65dd7eb87c3a852f97b50f4c4316f) fix issues - [`df3d3f1`](https://github.com/better-auth/better-auth/commit/df3d3f114fea64dccf71f5e60778d3e9a18d71b9) update docs - [`a51eec9`](https://github.com/better-auth/better-auth/commit/a51eec9b3f643dbf4737a7fea1c33b5bdd8be487) update docs - [`45213c6`](https://github.com/better-auth/better-auth/commit/45213c6a88b0480e0f1b05f0c3e60de5816924e3) add test - [`c9750cd`](https://github.com/better-auth/better-auth/commit/c9750cdb5e2669cca04be2d248a57e20fdbbfd54) fix test - [`cc50d5f`](https://github.com/better-auth/better-auth/commit/cc50d5f28f7c85d63ea28f8b167bfcf3429bc178) Update packages/better-auth/src/db/get-migration-schema.test.ts ### 📊 Changes **10 files changed** (+195 additions, -61 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/guides/create-a-db-adapter.mdx` (+1 -5) 📝 `docs/content/docs/reference/options.mdx` (+2 -4) 📝 `packages/better-auth/src/adapters/adapter-factory/index.ts` (+13 -11) 📝 `packages/better-auth/src/adapters/adapter-factory/test/adapter-factory.test.ts` (+38 -0) 📝 `packages/better-auth/src/db/get-migration-schema.test.ts` (+56 -2) 📝 `packages/better-auth/src/db/get-migration.ts` (+53 -34) 📝 `packages/cli/package.json` (+2 -0) ➕ `packages/cli/test/__snapshots__/migrations-uuid.sql` (+7 -0) 📝 `packages/core/src/types/init-options.ts` (+14 -2) 📝 `pnpm-lock.yaml` (+9 -3) </details> ### 📄 Description <!-- This is an auto-generated description by cubic. --> ## Summary by cubic Add first-class UUID support for IDs and standardize ID generation via advanced.database.generateId. Deprecates useNumberId and updates migrations/adapter logic to handle "uuid" and "serial" across Postgres, MySQL, and MSSQL. - **New Features** - generateId now accepts "uuid" and "serial". - Migrations create UUID columns and defaults: - Postgres: uuid type with default gen_random_uuid(). - MySQL/MSSQL: uuid type with default uuid(). - Validation updated: requesting numeric IDs ("serial"/useNumberId) throws if the adapter doesn’t support them. - Deprecation warning added for useNumberId; prefer generateId: "serial". - **Migration** - Replace useNumberId with generateId: "serial". - To enable UUIDs, set generateId: "uuid". - Postgres requires the pgcrypto extension for gen_random_uuid(). <sup>Written for commit cc50d5f28f7c85d63ea28f8b167bfcf3429bc178. 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-04-15 21:30:47 -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#23141