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