-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathschema.ts
37 lines (32 loc) · 969 Bytes
/
schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Message } from "ai";
import { InferSelectModel } from "drizzle-orm";
import {
pgTable,
varchar,
text,
real,
timestamp,
json,
} from "drizzle-orm/pg-core";
export const user = pgTable("User", {
email: varchar("email", { length: 64 }).primaryKey().notNull(),
password: varchar("password", { length: 64 }),
});
export const chat = pgTable("Chat", {
id: text("id").primaryKey().notNull(),
createdAt: timestamp("createdAt").notNull(),
messages: json("messages").notNull(),
author: varchar("author", { length: 64 })
.notNull()
.references(() => user.email),
});
export const chunk = pgTable("Chunk", {
id: text("id").primaryKey().notNull(),
filePath: text("filePath").notNull(),
content: text("content").notNull(),
embedding: real("embedding").array().notNull(),
});
export type Chat = Omit<InferSelectModel<typeof chat>, "messages"> & {
messages: Array<Message>;
};
export type Chunk = InferSelectModel<typeof chunk>;