124 lines
3.0 KiB
Plaintext
124 lines
3.0 KiB
Plaintext
|
|
// This is your Prisma schema file,
|
||
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||
|
|
|
||
|
|
generator client {
|
||
|
|
provider = "prisma-client-js"
|
||
|
|
}
|
||
|
|
|
||
|
|
datasource db {
|
||
|
|
provider = "mysql"
|
||
|
|
url = env("DATABASE_URL")
|
||
|
|
}
|
||
|
|
|
||
|
|
// 用户表
|
||
|
|
model User {
|
||
|
|
id String @id @default(cuid())
|
||
|
|
email String @unique
|
||
|
|
name String?
|
||
|
|
avatar String?
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
// 关联关系
|
||
|
|
templates Template[]
|
||
|
|
favorites Favorite[]
|
||
|
|
comments Comment[]
|
||
|
|
|
||
|
|
@@map("users")
|
||
|
|
}
|
||
|
|
|
||
|
|
// 提示词模板表
|
||
|
|
model Template {
|
||
|
|
id String @id @default(cuid())
|
||
|
|
title String
|
||
|
|
description String?
|
||
|
|
category String
|
||
|
|
tags String // JSON 格式存储标签数组
|
||
|
|
role String
|
||
|
|
task String
|
||
|
|
context String?
|
||
|
|
constraints String // JSON 格式存储约束数组
|
||
|
|
outputFormat String
|
||
|
|
variables String // JSON 格式存储变量数组
|
||
|
|
examples String? // JSON 格式存储示例数组
|
||
|
|
|
||
|
|
// 元数据
|
||
|
|
authorId String
|
||
|
|
author User @relation(fields: [authorId], references: [id], onDelete: Cascade)
|
||
|
|
isPublic Boolean @default(true)
|
||
|
|
isFeatured Boolean @default(false)
|
||
|
|
|
||
|
|
// 统计信息
|
||
|
|
usageCount Int @default(0)
|
||
|
|
rating Float @default(0)
|
||
|
|
ratingCount Int @default(0)
|
||
|
|
|
||
|
|
// 时间戳
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
// 关联关系
|
||
|
|
favorites Favorite[]
|
||
|
|
comments Comment[]
|
||
|
|
tests Test[]
|
||
|
|
|
||
|
|
@@map("templates")
|
||
|
|
}
|
||
|
|
|
||
|
|
// 收藏表
|
||
|
|
model Favorite {
|
||
|
|
id String @id @default(cuid())
|
||
|
|
userId String
|
||
|
|
templateId String
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
|
||
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||
|
|
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@unique([userId, templateId])
|
||
|
|
@@map("favorites")
|
||
|
|
}
|
||
|
|
|
||
|
|
// 评论表
|
||
|
|
model Comment {
|
||
|
|
id String @id @default(cuid())
|
||
|
|
content String
|
||
|
|
rating Int? // 1-5 星评分
|
||
|
|
userId String
|
||
|
|
templateId String
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
updatedAt DateTime @updatedAt
|
||
|
|
|
||
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||
|
|
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@map("comments")
|
||
|
|
}
|
||
|
|
|
||
|
|
// 测试记录表
|
||
|
|
model Test {
|
||
|
|
id String @id @default(cuid())
|
||
|
|
templateId String
|
||
|
|
input String // JSON 格式存储输入变量
|
||
|
|
output String? // 测试输出结果
|
||
|
|
model String // 使用的模型
|
||
|
|
parameters String // JSON 格式存储模型参数
|
||
|
|
status String // success, error, pending
|
||
|
|
duration Int? // 执行时间(毫秒)
|
||
|
|
createdAt DateTime @default(now())
|
||
|
|
|
||
|
|
template Template @relation(fields: [templateId], references: [id], onDelete: Cascade)
|
||
|
|
|
||
|
|
@@map("tests")
|
||
|
|
}
|
||
|
|
|
||
|
|
// 系统配置表
|
||
|
|
model SystemConfig {
|
||
|
|
id String @id @default(cuid())
|
||
|
|
key String @unique
|
||
|
|
value String
|
||
|
|
type String @default("string") // string, number, boolean, json
|
||
|
|
|
||
|
|
@@map("system_configs")
|
||
|
|
}
|