|
1 | | -import { boolean, pgEnum, pgTable, text, timestamp } from "drizzle-orm/pg-core"; |
2 | | - |
3 | | -import { nanoid } from "nanoid"; |
4 | | - |
5 | | -export const user = pgTable("user", { |
6 | | - id: text("id").primaryKey(), |
7 | | - name: text("name").notNull(), |
8 | | - email: text("email").notNull().unique(), |
9 | | - emailVerified: boolean("email_verified") |
10 | | - .$defaultFn(() => false) |
11 | | - .notNull(), |
12 | | - image: text("image"), |
13 | | - createdAt: timestamp("created_at") |
14 | | - .$defaultFn(() => /* @__PURE__ */ new Date()) |
15 | | - .notNull(), |
16 | | - updatedAt: timestamp("updated_at") |
17 | | - .$defaultFn(() => /* @__PURE__ */ new Date()) |
18 | | - .notNull(), |
19 | | -}); |
20 | | - |
21 | | -export const session = pgTable("session", { |
22 | | - id: text("id").primaryKey(), |
23 | | - expiresAt: timestamp("expires_at").notNull(), |
24 | | - token: text("token").notNull().unique(), |
25 | | - createdAt: timestamp("created_at").notNull(), |
26 | | - updatedAt: timestamp("updated_at").notNull(), |
27 | | - ipAddress: text("ip_address"), |
28 | | - userAgent: text("user_agent"), |
29 | | - userId: text("user_id") |
30 | | - .notNull() |
31 | | - .references(() => user.id, { onDelete: "cascade" }), |
32 | | -}); |
33 | | - |
34 | | -export const account = pgTable("account", { |
35 | | - id: text("id").primaryKey(), |
36 | | - accountId: text("account_id").notNull(), |
37 | | - providerId: text("provider_id").notNull(), |
38 | | - userId: text("user_id") |
39 | | - .notNull() |
40 | | - .references(() => user.id, { onDelete: "cascade" }), |
41 | | - accessToken: text("access_token"), |
42 | | - refreshToken: text("refresh_token"), |
43 | | - idToken: text("id_token"), |
44 | | - accessTokenExpiresAt: timestamp("access_token_expires_at"), |
45 | | - refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), |
46 | | - scope: text("scope"), |
47 | | - password: text("password"), |
48 | | - createdAt: timestamp("created_at").notNull(), |
49 | | - updatedAt: timestamp("updated_at").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").$defaultFn(() => /* @__PURE__ */ new Date()), |
58 | | - updatedAt: timestamp("updated_at").$defaultFn(() => /* @__PURE__ */ new Date()), |
59 | | -}); |
60 | | - |
61 | | -export const agents = pgTable("agents", { |
62 | | - id: text("id") |
63 | | - .primaryKey() |
64 | | - .$defaultFn(() => nanoid()), |
65 | | - name: text("name").notNull(), |
66 | | - userId: text("user_id") |
67 | | - .notNull() |
68 | | - .references(() => user.id, { onDelete: "cascade" }), |
69 | | - instructions: text("instructions").notNull(), |
70 | | - createdAt: timestamp("created_at").notNull().defaultNow(), |
71 | | - updatedAt: timestamp("updated_at").notNull().defaultNow(), |
72 | | -}); |
73 | | - |
74 | | -export const meetingStatus = pgEnum("meeting_status", [ |
75 | | - "upcomming", |
76 | | - "active", |
77 | | - "completed", |
78 | | - "processing", |
79 | | - "cancelled", |
80 | | -]); |
81 | | - |
82 | | -export const meetings = pgTable("meetings", { |
83 | | - id: text("id") |
84 | | - .primaryKey() |
85 | | - .$defaultFn(() => nanoid()), |
86 | | - name: text("name").notNull(), |
87 | | - userId: text("user_id") |
88 | | - .notNull() |
89 | | - .references(() => user.id, { onDelete: "cascade" }), |
90 | | - agentId: text("agent_id") |
91 | | - .notNull() |
92 | | - .references(() => agents.id, { onDelete: "cascade" }), |
93 | | - status: meetingStatus("status").notNull().default("upcomming"), |
94 | | - startedAt: timestamp("started_at"), |
95 | | - endedAt: timestamp("ended_at"), |
96 | | - transcriptUrl: text("transcript_url"), |
97 | | - recordingUrl: text("recording_url"), |
98 | | - summary: text("summary"), |
99 | | - createdAt: timestamp("created_at").notNull().defaultNow(), |
100 | | - updatedAt: timestamp("updated_at").notNull().defaultNow(), |
101 | | -}); |
| 1 | +import { boolean, pgEnum, pgTable, text, timestamp } from "drizzle-orm/pg-core"; |
| 2 | + |
| 3 | +import { nanoid } from "nanoid"; |
| 4 | + |
| 5 | +export const user = pgTable("user", { |
| 6 | + id: text("id").primaryKey(), |
| 7 | + name: text("name").notNull(), |
| 8 | + email: text("email").notNull().unique(), |
| 9 | + emailVerified: boolean("email_verified") |
| 10 | + .$defaultFn(() => false) |
| 11 | + .notNull(), |
| 12 | + image: text("image"), |
| 13 | + createdAt: timestamp("created_at") |
| 14 | + .$defaultFn(() => /* @__PURE__ */ new Date()) |
| 15 | + .notNull(), |
| 16 | + updatedAt: timestamp("updated_at") |
| 17 | + .$defaultFn(() => /* @__PURE__ */ new Date()) |
| 18 | + .notNull(), |
| 19 | +}); |
| 20 | + |
| 21 | +export const session = pgTable("session", { |
| 22 | + id: text("id").primaryKey(), |
| 23 | + expiresAt: timestamp("expires_at").notNull(), |
| 24 | + token: text("token").notNull().unique(), |
| 25 | + createdAt: timestamp("created_at").notNull(), |
| 26 | + updatedAt: timestamp("updated_at").notNull(), |
| 27 | + ipAddress: text("ip_address"), |
| 28 | + userAgent: text("user_agent"), |
| 29 | + userId: text("user_id") |
| 30 | + .notNull() |
| 31 | + .references(() => user.id, { onDelete: "cascade" }), |
| 32 | +}); |
| 33 | + |
| 34 | +export const account = pgTable("account", { |
| 35 | + id: text("id").primaryKey(), |
| 36 | + accountId: text("account_id").notNull(), |
| 37 | + providerId: text("provider_id").notNull(), |
| 38 | + userId: text("user_id") |
| 39 | + .notNull() |
| 40 | + .references(() => user.id, { onDelete: "cascade" }), |
| 41 | + accessToken: text("access_token"), |
| 42 | + refreshToken: text("refresh_token"), |
| 43 | + idToken: text("id_token"), |
| 44 | + accessTokenExpiresAt: timestamp("access_token_expires_at"), |
| 45 | + refreshTokenExpiresAt: timestamp("refresh_token_expires_at"), |
| 46 | + scope: text("scope"), |
| 47 | + password: text("password"), |
| 48 | + createdAt: timestamp("created_at").notNull(), |
| 49 | + updatedAt: timestamp("updated_at").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").$defaultFn( |
| 58 | + () => /* @__PURE__ */ new Date(), |
| 59 | + ), |
| 60 | + updatedAt: timestamp("updated_at").$defaultFn( |
| 61 | + () => /* @__PURE__ */ new Date(), |
| 62 | + ), |
| 63 | +}); |
| 64 | + |
| 65 | +export const agents = pgTable("agents", { |
| 66 | + id: text("id") |
| 67 | + .primaryKey() |
| 68 | + .$defaultFn(() => nanoid()), |
| 69 | + name: text("name").notNull(), |
| 70 | + userId: text("user_id") |
| 71 | + .notNull() |
| 72 | + .references(() => user.id, { onDelete: "cascade" }), |
| 73 | + instructions: text("instructions").notNull(), |
| 74 | + createdAt: timestamp("created_at").notNull().defaultNow(), |
| 75 | + updatedAt: timestamp("updated_at").notNull().defaultNow(), |
| 76 | +}); |
| 77 | + |
| 78 | +export const meetingStatus = pgEnum("meeting_status", [ |
| 79 | + "upcomming", |
| 80 | + "active", |
| 81 | + "completed", |
| 82 | + "processing", |
| 83 | + "cancelled", |
| 84 | +]); |
| 85 | + |
| 86 | +export const meetings = pgTable("meetings", { |
| 87 | + id: text("id") |
| 88 | + .primaryKey() |
| 89 | + .$defaultFn(() => nanoid()), |
| 90 | + name: text("name").notNull(), |
| 91 | + userId: text("user_id") |
| 92 | + .notNull() |
| 93 | + .references(() => user.id, { onDelete: "cascade" }), |
| 94 | + agentId: text("agent_id") |
| 95 | + .notNull() |
| 96 | + .references(() => agents.id, { onDelete: "cascade" }), |
| 97 | + status: meetingStatus("status").notNull().default("upcomming"), |
| 98 | + startedAt: timestamp("started_at"), |
| 99 | + endedAt: timestamp("ended_at"), |
| 100 | + transcriptUrl: text("transcript_url"), |
| 101 | + recordingUrl: text("recording_url"), |
| 102 | + summary: text("summary"), |
| 103 | + createdAt: timestamp("created_at").notNull().defaultNow(), |
| 104 | + updatedAt: timestamp("updated_at").notNull().defaultNow(), |
| 105 | +}); |
0 commit comments