feat: 工作台聊天室功能

This commit is contained in:
2026-05-31 02:37:23 +08:00
parent 83cf9eab94
commit f83f434863
33 changed files with 2520 additions and 265 deletions

View File

@@ -45,6 +45,38 @@ export const models = sqliteTable(
],
);
export const conversations = sqliteTable(
"conversations",
{
createdAt: text("created_at").notNull(),
id: text("id").primaryKey(),
modelId: text("model_id")
.notNull()
.references(() => models.id),
projectId: text("project_id")
.notNull()
.references(() => projects.id),
title: text("title").notNull().default("新会话"),
updatedAt: text("updated_at").notNull(),
},
(table) => [index("conversations_project_id_idx").on(table.projectId)],
);
export const messages = sqliteTable(
"messages",
{
content: text("content").notNull().default(""),
conversationId: text("conversation_id")
.notNull()
.references(() => conversations.id, { onDelete: "cascade" }),
createdAt: text("created_at").notNull(),
id: text("id").primaryKey(),
parts: text("parts"),
role: text("role", { enum: ["assistant", "system", "user"] }).notNull(),
},
(table) => [index("messages_conversation_id_idx").on(table.conversationId)],
);
export const schemaMigrations = sqliteTable("schema_migrations", {
appliedAt: text("applied_at").notNull(),
checksum: text("checksum").notNull(),