From 33b9076cd36e891e0b086d1fb61540e0def6ca0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20Tonh=C3=A4user?= Date: Mon, 10 Aug 2026 23:41:47 +0200 Subject: [PATCH] fix(auth): generate UUID ids to match uuid schema columns Better Auth's default id generator emits a nanoid-style string, but every id column in the schema is typed uuid. Better Auth passes its generated id explicitly on insert (bypassing the column defaultRandom), so Postgres rejected every signUp/session/verification insert with 'invalid input syntax for type uuid'. This broke live registration and the admin seed alike. Configure advanced.database.generateId to return crypto.randomUUID() so ids match the schema. Co-Authored-By: Claude --- src/modules/auth/auth.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/auth/auth.ts b/src/modules/auth/auth.ts index c69e7e9..b7f103c 100644 --- a/src/modules/auth/auth.ts +++ b/src/modules/auth/auth.ts @@ -29,6 +29,11 @@ export function createPortalAuth({ baseURL: env.BETTER_AUTH_URL, secret: env.BETTER_AUTH_SECRET, database, + // All id columns are typed `uuid`; Better Auth's default id generator emits + // a nanoid-style string that Postgres rejects with "invalid input syntax + // for type uuid". Generate real UUIDs so inserts (signUp, sessions, + // verifications) match the schema. + advanced: { database: { generateId: () => crypto.randomUUID() } }, emailAndPassword: { enabled: true, requireEmailVerification: true,