You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* - Supports anonymous authentication alongside email/password and Google OAuth
106
106
*
107
107
* @param db Drizzle database instance - must include all required auth tables (user, session, identity, organization, member, invitation, verification)
@@ -201,7 +201,7 @@ export function createAuth(
201
201
202
202
advanced: {
203
203
database: {
204
-
generateId: false,
204
+
generateId: ({ model })=>generateAuthId(modelasAuthModel),
Copy file name to clipboardExpand all lines: db/AGENTS.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
## Schema Conventions
2
2
3
3
- Drizzle `casing: "snake_case"` — use camelCase in TypeScript, columns map to snake_case in DB.
4
-
- All primary keys: `text().primaryKey().default(sql`gen_random_uuid()`)`.
4
+
- All primary keys: `text().primaryKey().$defaultFn(() => generateAuthId(...))` — application-generated prefixed CUID2 IDs (e.g. `usr_ght4k2jxm7pqbv01`). See `db/schema/id.ts` for prefix map.
5
5
- Timestamps: `timestamp({ withTimezone: true, mode: "date" })`. Every table has `createdAt` (`.defaultNow().notNull()`) and `updatedAt` (`.defaultNow().$onUpdate(() => new Date()).notNull()`).
6
6
-`identity` table = Better Auth's `account` table, renamed via `account.modelName: "identity"` in auth config.
7
7
-`member.role` and `invitation.status` are free `text`, not pgEnum — avoids fragile coupling with Better Auth's values.
All primary keys use application-generated prefixed CUID2 IDs (e.g. `usr_ght4k2jxm7pqbv01`). IDs are generated at the application level via `$defaultFn()` — no database-level defaults. See `db/schema/id.ts` for the prefix map and `docs/specs/prefixed-ids.md` for design rationale.
0 commit comments