[PR #5985] [MERGED] chore(fix): support native UUID generation #23263

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/5985
Author: @mrl5
Created: 11/14/2025
Status: Merged
Merged: 11/14/2025
Merged by: @Bekacru

Base: canaryHead: fix-support-native-uuid-gen


📝 Commits (1)

  • df688f5 fix(db): support native UUID generation

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 packages/better-auth/src/adapters/adapter-factory/index.ts (+2 -2)

📄 Description

follow up for #5823 - current logic was still relying on JS

can be easily tested with:

alter table "user" alter column id set default '00000000-0000-0000-0000-000000000000'::uuid;
import { Pool } from 'pg';
import { betterAuth } from './index.mjs';
import { getMigrations } from './db/index.mjs';

export async function runMigrations(auth) {
  try {
    const migration = await getMigrations(auth.options);
    console.log(`Running migrations`);
    await migration.runMigrations();
    console.log('Migrations run successfully');
  } catch (error) {
    console.error(error);
    throw error;
  }
}

const connectionString = '...'; // put conn str here

export const a = betterAuth({
    database: new Pool({
      connectionString,
    }),
    emailAndPassword: {
        enabled: true,
    },
    advanced: {
      database: {
        generateId: "uuid",
      },
    }
});

await runMigrations(a);
await a.api.signUpEmail({ body: { email: "test2@test.com", password: "2test123456", name: "test user2" } });

Summary by cubic

Fix the UUID generation logic to defer to the database when native UUIDs are supported. We now only generate UUIDs in JS when the database does not support them (config.supportsUUIDs is false).

Written for commit df688f58d8. 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/5985 **Author:** [@mrl5](https://github.com/mrl5) **Created:** 11/14/2025 **Status:** ✅ Merged **Merged:** 11/14/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `fix-support-native-uuid-gen` --- ### 📝 Commits (1) - [`df688f5`](https://github.com/better-auth/better-auth/commit/df688f58d80f0a84dc0391eb4b87d3f1110e4774) fix(db): support native UUID generation ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/adapter-factory/index.ts` (+2 -2) </details> ### 📄 Description follow up for #5823 - current logic was still relying on JS can be easily tested with: ```sql alter table "user" alter column id set default '00000000-0000-0000-0000-000000000000'::uuid; ``` ```js import { Pool } from 'pg'; import { betterAuth } from './index.mjs'; import { getMigrations } from './db/index.mjs'; export async function runMigrations(auth) { try { const migration = await getMigrations(auth.options); console.log(`Running migrations`); await migration.runMigrations(); console.log('Migrations run successfully'); } catch (error) { console.error(error); throw error; } } const connectionString = '...'; // put conn str here export const a = betterAuth({ database: new Pool({ connectionString, }), emailAndPassword: { enabled: true, }, advanced: { database: { generateId: "uuid", }, } }); await runMigrations(a); await a.api.signUpEmail({ body: { email: "test2@test.com", password: "2test123456", name: "test user2" } }); ``` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fix the UUID generation logic to defer to the database when native UUIDs are supported. We now only generate UUIDs in JS when the database does not support them (config.supportsUUIDs is false). <sup>Written for commit df688f58d80f0a84dc0391eb4b87d3f1110e4774. 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:34:56 -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#23263