24 lines
772 B
TypeScript
24 lines
772 B
TypeScript
import { Message } from "ai";
|
|
import { InferSelectModel } from "drizzle-orm";
|
|
import { pgTable, varchar, timestamp, json, uuid } from "drizzle-orm/pg-core";
|
|
|
|
export const user = pgTable("User", {
|
|
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
|
email: varchar("email", { length: 64 }).notNull(),
|
|
password: varchar("password", { length: 64 }),
|
|
});
|
|
|
|
export type User = InferSelectModel<typeof user>;
|
|
|
|
export const chat = pgTable("Chat", {
|
|
id: uuid("id").primaryKey().notNull().defaultRandom(),
|
|
createdAt: timestamp("createdAt").notNull(),
|
|
messages: json("messages").notNull(),
|
|
userId: uuid("userId")
|
|
.notNull()
|
|
.references(() => user.id),
|
|
});
|
|
|
|
export type Chat = Omit<InferSelectModel<typeof chat>, "messages"> & {
|
|
messages: Array<Message>;
|
|
};
|