design database
This commit is contained in:
@@ -36,3 +36,55 @@ import {
|
||||
import { sql } from "drizzle-orm";
|
||||
|
||||
import { id, createdAt, updatedAt } from "../common";
|
||||
|
||||
// 引用其他schema中的表
|
||||
import { user } from "./auth.db";
|
||||
import { attributeFile } from "./basic.db";
|
||||
|
||||
// 枚举定义
|
||||
export const generationStatusEnum = pgEnum("generation_status", [
|
||||
"pending",
|
||||
"processing",
|
||||
"completed",
|
||||
"failed"
|
||||
]);
|
||||
|
||||
// 项目表:用户创建的项目
|
||||
export const nvwaProject = pgTable("nvwa_project", {
|
||||
id,
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
description: text("description"),
|
||||
userId: text("user_id")
|
||||
.notNull()
|
||||
.references(() => user.id, { onDelete: "cascade" }),
|
||||
createdAt,
|
||||
updatedAt,
|
||||
});
|
||||
|
||||
// 线框图表:属于项目的线框图,包含画布数据和描述
|
||||
export const nvwaWireframe = pgTable("nvwa_wireframe", {
|
||||
id,
|
||||
projectId: integer("project_id")
|
||||
.notNull()
|
||||
.references(() => nvwaProject.id, { onDelete: "cascade" }),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
canvasData: jsonb("canvas_data"), // 存储画布上的元素和布局数据
|
||||
description: text("description"), // 用户输入的文本描述,用于指导AI生成
|
||||
uploadedFileId: integer("uploaded_file_id").references(() => attributeFile.id, { onDelete: "set null" }), // 上传的草图文件ID
|
||||
createdAt,
|
||||
updatedAt,
|
||||
});
|
||||
|
||||
// 生成表:AI生成的任务和结果
|
||||
export const nvwaGeneration = pgTable("nvwa_generation", {
|
||||
id,
|
||||
wireframeId: integer("wireframe_id")
|
||||
.notNull()
|
||||
.references(() => nvwaWireframe.id, { onDelete: "cascade" }),
|
||||
prompt: text("prompt").notNull(), // AI生成的提示词
|
||||
status: generationStatusEnum("status").default("pending").notNull(),
|
||||
generatedImageUrl: varchar("generated_image_url", { length: 500 }), // 生成的图像URL
|
||||
errorMessage: text("error_message"), // 如果生成失败,存储错误信息
|
||||
createdAt,
|
||||
updatedAt,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user