|
| 1 | +import { pgTable, text, timestamp, boolean } from "drizzle-orm/pg-core"; |
| 2 | + |
| 3 | +export const user = pgTable("user", { |
| 4 | + id: text("id").primaryKey(), |
| 5 | + name: text("name").notNull(), |
| 6 | + email: text("email").notNull().unique(), |
| 7 | + emailVerified: boolean("email_verified").default(false).notNull(), |
| 8 | + image: text("image"), |
| 9 | + createdAt: timestamp("created_at").defaultNow().notNull(), |
| 10 | + updatedAt: timestamp("updated_at") |
| 11 | + .defaultNow() |
| 12 | + .$onUpdate(() => /* @__PURE__ */ new Date()) |
| 13 | + .notNull(), |
| 14 | + isAnonymous: boolean("is_anonymous"), |
| 15 | +}); |
| 16 | + |
| 17 | +export const session = pgTable("session", { |
| 18 | + id: text("id").primaryKey(), |
| 19 | + expiresAt: timestamp("expires_at").notNull(), |
| 20 | + token: text("token").notNull().unique(), |
| 21 | + createdAt: timestamp("created_at").defaultNow().notNull(), |
| 22 | + updatedAt: timestamp("updated_at") |
| 23 | + .$onUpdate(() => /* @__PURE__ */ new Date()) |
| 24 | + .notNull(), |
| 25 | + ipAddress: text("ip_address"), |
| 26 | + userAgent: text("user_agent"), |
| 27 | + userId: text("user_id") |
| 28 | + .notNull() |
| 29 | + .references(() => user.id, { onDelete: "cascade" }), |
| 30 | +}); |
| 31 | + |
| 32 | +export const account = pgTable("account", { |
| 33 | + id: text("id").primaryKey(), |
| 34 | + accountId: text("account_id").notNull(), |
| 35 | + providerId: text("provider_id").notNull(), |
| 36 | + userId: text("user_id") |
| 37 | + .notNull() |
| 38 | + .references(() => user.id, { onDelete: "cascade" }), |
| 39 | + accessToken: text("access_token"), |
| 40 | + refreshToken: text("refresh_token"), |
| 41 | + idToken: text("id_token"), |
| 42 | + accessTokenExpiresAt: timestamp("access_token_expires_at"), |
| 43 | + refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), |
| 44 | + scope: text("scope"), |
| 45 | + password: text("password"), |
| 46 | + createdAt: timestamp("created_at").defaultNow().notNull(), |
| 47 | + updatedAt: timestamp("updated_at") |
| 48 | + .$onUpdate(() => /* @__PURE__ */ new Date()) |
| 49 | + .notNull(), |
| 50 | +}); |
| 51 | + |
| 52 | +export const verification = pgTable("verification", { |
| 53 | + id: text("id").primaryKey(), |
| 54 | + identifier: text("identifier").notNull(), |
| 55 | + value: text("value").notNull(), |
| 56 | + expiresAt: timestamp("expires_at").notNull(), |
| 57 | + createdAt: timestamp("created_at").defaultNow().notNull(), |
| 58 | + updatedAt: timestamp("updated_at") |
| 59 | + .defaultNow() |
| 60 | + .$onUpdate(() => /* @__PURE__ */ new Date()) |
| 61 | + .notNull(), |
| 62 | +}); |
0 commit comments