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