fix #12: simplify auth adapter, add verifications table
This commit is contained in:
8
drizzle/0003_add_verifications_table.sql
Normal file
8
drizzle/0003_add_verifications_table.sql
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS "verifications" (
|
||||||
|
"id" text PRIMARY KEY NOT NULL,
|
||||||
|
"identifier" text NOT NULL,
|
||||||
|
"value" text NOT NULL,
|
||||||
|
"expires_at" timestamp NOT NULL,
|
||||||
|
"created_at" timestamp with time zone DEFAULT now(),
|
||||||
|
"updated_at" timestamp with time zone DEFAULT now()
|
||||||
|
);
|
||||||
@@ -22,6 +22,13 @@
|
|||||||
"when": 1777066400000,
|
"when": 1777066400000,
|
||||||
"tag": "0002_add_accounts_table",
|
"tag": "0002_add_accounts_table",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 3,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1777066500000,
|
||||||
|
"tag": "0003_add_verifications_table",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,10 @@
|
|||||||
import { betterAuth } from "better-auth";
|
import { betterAuth } from "better-auth";
|
||||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||||
import { db } from "./db";
|
import { db } from "./db";
|
||||||
import { users, sessions, accounts } from "./db/schema";
|
|
||||||
|
|
||||||
export const auth = betterAuth({
|
export const auth = betterAuth({
|
||||||
database: drizzleAdapter(db, {
|
database: drizzleAdapter(db, {
|
||||||
provider: "pg",
|
provider: "pg",
|
||||||
schema: {
|
|
||||||
user: users,
|
|
||||||
session: sessions,
|
|
||||||
account: accounts,
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
emailAndPassword: { enabled: true },
|
emailAndPassword: { enabled: true },
|
||||||
session: { expiresIn: 60 * 60 * 24 * 7 },
|
session: { expiresIn: 60 * 60 * 24 * 7 },
|
||||||
|
|||||||
@@ -38,6 +38,15 @@ export const accounts = pgTable("accounts", {
|
|||||||
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
|
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow().notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const verifications = pgTable("verifications", {
|
||||||
|
id: text("id").primaryKey().$defaultFn(() => createId()),
|
||||||
|
identifier: text("identifier").notNull(),
|
||||||
|
value: text("value").notNull(),
|
||||||
|
expiresAt: timestamp("expires_at").notNull(),
|
||||||
|
createdAt: timestamp("created_at", { withTimezone: true }).defaultNow(),
|
||||||
|
updatedAt: timestamp("updated_at", { withTimezone: true }).defaultNow(),
|
||||||
|
});
|
||||||
|
|
||||||
export const comparisonStatusEnum = pgEnum("comparison_status", [
|
export const comparisonStatusEnum = pgEnum("comparison_status", [
|
||||||
"researching",
|
"researching",
|
||||||
"completed",
|
"completed",
|
||||||
|
|||||||
Reference in New Issue
Block a user