refactor: update user and authentication schema with two-factor support

This commit is contained in:
Mauricio Siu
2025-02-16 15:32:57 -06:00
parent 90156da570
commit e1632cbdb3
33 changed files with 657 additions and 180 deletions

View File

@@ -1,9 +1,9 @@
import {
boolean,
integer,
pgTable,
text,
integer,
timestamp,
boolean,
} from "drizzle-orm/pg-core";
export const users_temp = pgTable("users_temp", {
@@ -14,6 +14,7 @@ export const users_temp = pgTable("users_temp", {
image: text("image"),
createdAt: timestamp("created_at").notNull(),
updatedAt: timestamp("updated_at").notNull(),
twoFactorEnabled: boolean("two_factor_enabled"),
role: text("role").notNull(),
ownerId: text("owner_id").notNull(),
});
@@ -59,6 +60,15 @@ export const verification = pgTable("verification", {
updatedAt: timestamp("updated_at"),
});
export const twoFactor = pgTable("two_factor", {
id: text("id").primaryKey(),
secret: text("secret").notNull(),
backupCodes: text("backup_codes").notNull(),
userId: text("user_id")
.notNull()
.references(() => users_temp.id, { onDelete: "cascade" }),
});
export const organization = pgTable("organization", {
id: text("id").primaryKey(),
name: text("name").notNull(),