Samuel Shuert | 341d4a6 | 2024-02-04 14:51:12 -0500 | [diff] [blame] | 1 | import { |
| 2 | timestamp, |
| 3 | pgTable, |
| 4 | text, |
| 5 | primaryKey, |
| 6 | integer |
| 7 | } from "drizzle-orm/pg-core" |
| 8 | import type { AdapterAccount } from '@auth/core/adapters' |
| 9 | |
| 10 | export const users = pgTable("user", { |
| 11 | id: text("id").notNull().primaryKey(), |
| 12 | name: text("name"), |
| 13 | email: text("email").notNull(), |
| 14 | emailVerified: timestamp("emailVerified", { mode: "date" }), |
| 15 | image: text("image"), |
| 16 | }) |
| 17 | |
| 18 | export const accounts = pgTable( |
| 19 | "account", |
| 20 | { |
| 21 | userId: text("userId") |
| 22 | .notNull() |
| 23 | .references(() => users.id, { onDelete: "cascade" }), |
| 24 | type: text("type").$type<AdapterAccount["type"]>().notNull(), |
| 25 | provider: text("provider").notNull(), |
| 26 | providerAccountId: text("providerAccountId").notNull(), |
| 27 | refresh_token: text("refresh_token"), |
| 28 | access_token: text("access_token"), |
| 29 | expires_at: integer("expires_at"), |
| 30 | token_type: text("token_type"), |
| 31 | scope: text("scope"), |
| 32 | id_token: text("id_token"), |
| 33 | session_state: text("session_state"), |
| 34 | }, |
| 35 | (account) => ({ |
| 36 | compoundKey: primaryKey({ columns: [account.provider, account.providerAccountId] }), |
| 37 | }) |
| 38 | ) |
| 39 | |
| 40 | export const sessions = pgTable("session", { |
| 41 | sessionToken: text("sessionToken").notNull().primaryKey(), |
| 42 | userId: text("userId") |
| 43 | .notNull() |
| 44 | .references(() => users.id, { onDelete: "cascade" }), |
| 45 | expires: timestamp("expires", { mode: "date" }).notNull(), |
| 46 | }) |
| 47 | |
| 48 | export const verificationTokens = pgTable( |
| 49 | "verificationToken", |
| 50 | { |
| 51 | identifier: text("identifier").notNull(), |
| 52 | token: text("token").notNull(), |
| 53 | expires: timestamp("expires", { mode: "date" }).notNull(), |
| 54 | }, |
| 55 | (vt) => ({ |
| 56 | compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }), |
| 57 | }) |
| 58 | ) |
| 59 | |
| 60 | export const lots = pgTable("lots", { |
| 61 | |
| 62 | }) |