添加语义搜索能力,支持自然语言查询找到相关项目。 - 数据库:新增 embedding 字段用于向量存储 - 前端:新增 AI 搜索栏和结果组件,支持传统/AI 模式切换 - API:新增 /api/search/ai 端点处理语义搜索请求 - 国际化:添加 AI 搜索相关中英文翻译 - 探索任务:允许 FAILED 状态直接转到 IN_PROGRESS 简化重试 Co-Authored-By: Claude <noreply@anthropic.com>
149 lines
3.5 KiB
Plaintext
149 lines
3.5 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"
|
||
previewFeatures = ["postgresqlExtensions"]
|
||
}
|
||
|
||
datasource db {
|
||
provider = "postgresql"
|
||
url = env("DATABASE_URL")
|
||
}
|
||
|
||
// ================================
|
||
// Enums
|
||
// ================================
|
||
|
||
enum ProjectStatus {
|
||
ACTIVE
|
||
ARCHIVED
|
||
}
|
||
|
||
enum LinkType {
|
||
WEBSITE
|
||
GITHUB
|
||
HUGGINGFACE
|
||
PAPER
|
||
}
|
||
|
||
enum TaskStatus {
|
||
PENDING
|
||
IN_PROGRESS
|
||
COMPLETED
|
||
FAILED
|
||
}
|
||
|
||
// ================================
|
||
// Models
|
||
// ================================
|
||
|
||
model Project {
|
||
id String @id @default(cuid())
|
||
name String
|
||
nameEn String?
|
||
slug String @unique
|
||
description String
|
||
descriptionEn String?
|
||
content String? @db.Text
|
||
contentEn String? @db.Text
|
||
status ProjectStatus @default(ACTIVE)
|
||
source String?
|
||
embedding Unsupported("vector(1536)")?
|
||
embeddingUpdatedAt DateTime?
|
||
createdAt DateTime @default(now())
|
||
updatedAt DateTime @updatedAt
|
||
|
||
// Relations
|
||
tags ProjectTag[]
|
||
links ExternalLink[]
|
||
discoveryTasks ProjectDiscoveryTask[]
|
||
|
||
// Indexes
|
||
@@index([status, createdAt], map: "idx_project_status_createdAt")
|
||
@@index([slug], map: "idx_project_slug")
|
||
@@map("projects")
|
||
}
|
||
|
||
model Tag {
|
||
id String @id @default(cuid())
|
||
name String @unique
|
||
nameEn String?
|
||
slug String @unique
|
||
createdAt DateTime @default(now())
|
||
|
||
// Relations
|
||
projects ProjectTag[]
|
||
|
||
// Indexes
|
||
@@index([slug], map: "idx_tag_slug")
|
||
@@map("tags")
|
||
}
|
||
|
||
model ExternalLink {
|
||
id String @id @default(cuid())
|
||
type LinkType
|
||
url String
|
||
title String?
|
||
projectId String
|
||
|
||
// Relations
|
||
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||
|
||
// Indexes
|
||
@@index([projectId], map: "idx_link_projectId")
|
||
@@index([type], map: "idx_link_type")
|
||
@@index([url], map: "idx_link_url")
|
||
@@index([type, url], map: "idx_link_type_url")
|
||
@@unique([projectId, url])
|
||
@@map("external_links")
|
||
}
|
||
|
||
// Project-Tag many-to-many relationship table
|
||
model ProjectTag {
|
||
projectId String
|
||
tagId String
|
||
|
||
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
||
tag Tag @relation(fields: [tagId], references: [id], onDelete: Cascade)
|
||
|
||
@@id([projectId, tagId])
|
||
@@index([tagId])
|
||
@@map("project_tags")
|
||
}
|
||
|
||
// Project Discovery Task model
|
||
model ProjectDiscoveryTask {
|
||
id String @id @default(cuid())
|
||
status TaskStatus @default(PENDING)
|
||
|
||
// 原始数据(仅URL)
|
||
sourceUrl String
|
||
sourceType String @default("manual")
|
||
|
||
// 探索结果
|
||
explorationData Json?
|
||
explorationSummary String? @db.Text
|
||
|
||
// 错误处理
|
||
errorMessage String? @db.Text
|
||
retryCount Int @default(0)
|
||
lastRetryAt DateTime?
|
||
|
||
// 关联
|
||
projectId String?
|
||
project Project? @relation(fields: [projectId], references: [id])
|
||
|
||
// 时间戳
|
||
createdAt DateTime @default(now())
|
||
startedAt DateTime?
|
||
completedAt DateTime?
|
||
updatedAt DateTime @updatedAt
|
||
|
||
// 索引
|
||
@@index([status, createdAt], map: "idx_task_status_created")
|
||
@@index([sourceUrl], map: "idx_task_source_url")
|
||
@@index([projectId], map: "idx_task_project_id")
|
||
@@map("project_discovery_tasks")
|
||
}
|