fix(auth): add account, session, and verification schemas; make passwordHash nullable

This commit is contained in:
2026-01-30 18:10:00 +00:00
parent e5814e1914
commit f1919ca0e1
5 changed files with 20 additions and 3 deletions

View File

@@ -16,6 +16,9 @@ export const auth = betterAuth({
schema: { schema: {
...schema, ...schema,
user: schema.users, user: schema.users,
account: schema.accounts,
session: schema.sessions,
verification: schema.verifications,
}, },
}), }),
advanced: { advanced: {

View File

@@ -4,7 +4,7 @@ export const users = pgTable('users', {
id: uuid('id').defaultRandom().primaryKey(), id: uuid('id').defaultRandom().primaryKey(),
email: varchar('email', { length: 255 }).notNull().unique(), email: varchar('email', { length: 255 }).notNull().unique(),
name: varchar('name', { length: 255 }).notNull(), name: varchar('name', { length: 255 }).notNull(),
passwordHash: varchar('password_hash', { length: 255 }).notNull(), passwordHash: varchar('password_hash', { length: 255 }),
emailVerified: boolean('email_verified').default(false).notNull(), emailVerified: boolean('email_verified').default(false).notNull(),
image: text('image'), image: text('image'),
createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(), createdAt: timestamp('created_at', { withTimezone: true }).defaultNow().notNull(),

View File

@@ -0,0 +1 @@
ALTER TABLE "users" ALTER COLUMN "password_hash" DROP NOT NULL;

View File

@@ -92,6 +92,13 @@
"when": 1770740394562, "when": 1770740394562,
"tag": "0012_natural_daredevil", "tag": "0012_natural_daredevil",
"breakpoints": true "breakpoints": true
},
{
"idx": 13,
"version": "7",
"when": 1770800000000,
"tag": "0013_users_password_hash_nullable",
"breakpoints": true
} }
] ]
} }

View File

@@ -127,7 +127,13 @@
const payload = await response.json().catch(() => ({})); const payload = await response.json().catch(() => ({}));
if (!response.ok) { if (!response.ok) {
throw new Error(payload.message || response.statusText); const errorMessage =
payload?.message ||
payload?.error?.message ||
payload?.error ||
payload?.code ||
`${response.status} ${response.statusText}`;
throw new Error(errorMessage);
} }
return payload; return payload;