- 移除 n8n-workflows 目录下的工作流配置文件 - 从 Project 模型移除 embedding 和 embeddingUpdatedAt 字段 - 添加 N8N_AI_SEARCH_WEBHOOK 环境变量配置 Co-Authored-By: Claude (glm-4.7) <noreply@anthropic.com>
147 lines
3.4 KiB
Plaintext
147 lines
3.4 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?
|
||
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")
|
||
}
|