fix #12: add accounts table for Better Auth credential storage
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { betterAuth } from "better-auth";
|
||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
import { db } from "./db";
|
||||
import { users, sessions } from "./db/schema";
|
||||
import { users, sessions, accounts } from "./db/schema";
|
||||
|
||||
export const auth = betterAuth({
|
||||
database: drizzleAdapter(db, {
|
||||
@@ -9,6 +9,7 @@ export const auth = betterAuth({
|
||||
schema: {
|
||||
user: users,
|
||||
session: sessions,
|
||||
account: accounts,
|
||||
},
|
||||
}),
|
||||
emailAndPassword: { enabled: true },
|
||||
|
||||
@@ -20,6 +20,24 @@ export const users = pgTable("users", {
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export const accounts = pgTable("accounts", {
|
||||
id: text("id").primaryKey().$defaultFn(() => createId()),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
accountId: text("account_id").notNull(),
|
||||
providerId: text("provider_id").notNull(),
|
||||
accessToken: text("access_token"),
|
||||
refreshToken: text("refresh_token"),
|
||||
accessTokenExpiresAt: timestamp("access_token_expires_at"),
|
||||
refreshTokenExpiresAt: timestamp("refresh_token_expires_at"),
|
||||
scope: text("scope"),
|
||||
idToken: text("id_token"),
|
||||
password: text("password"),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
|
||||
});
|
||||
|
||||
export const comparisonStatusEnum = pgEnum("comparison_status", [
|
||||
"researching",
|
||||
"completed",
|
||||
|
||||
Reference in New Issue
Block a user