feat: 知识库新模型 — KnowledgeSource/KnowledgeChunk/ImportCandidate/BackupJob/MembershipPlan
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 1m16s
All checks were successful
Deploy API Server / build-and-deploy (push) Successful in 1m16s
This commit is contained in:
parent
6db19c8ac8
commit
df56a76079
@ -46,6 +46,9 @@ model User {
|
||||
notifications Notification[]
|
||||
feedbacks Feedback[]
|
||||
aiUsageLogs AiUsageLog[]
|
||||
knowledgeSources KnowledgeSource[]
|
||||
knowledgeChunks KnowledgeChunk[]
|
||||
importCandidates ImportCandidate[]
|
||||
|
||||
@@index([email])
|
||||
@@index([status])
|
||||
@ -143,6 +146,9 @@ model KnowledgeBase {
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
items KnowledgeItem[]
|
||||
sources KnowledgeSource[]
|
||||
candidates ImportCandidate[]
|
||||
chunks KnowledgeChunk[]
|
||||
focusItems FocusItem[]
|
||||
|
||||
@@index([userId])
|
||||
@ -150,21 +156,24 @@ model KnowledgeBase {
|
||||
}
|
||||
|
||||
model KnowledgeItem {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
knowledgeBaseId String
|
||||
parentId String?
|
||||
itemType String @db.VarChar(32)
|
||||
title String @db.VarChar(255)
|
||||
content String? @db.LongText
|
||||
summary String? @db.Text
|
||||
sourceType String? @db.VarChar(32)
|
||||
sourceRef String? @db.VarChar(500)
|
||||
orderIndex Int @default(0)
|
||||
status String @default("active") @db.VarChar(32)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
knowledgeBaseId String
|
||||
parentId String?
|
||||
itemType String @db.VarChar(32)
|
||||
title String @db.VarChar(255)
|
||||
content String? @db.LongText
|
||||
summary String? @db.Text
|
||||
sourceType String? @db.VarChar(32)
|
||||
sourceRef String? @db.VarChar(500)
|
||||
sourceDeleted Boolean @default(false)
|
||||
sourceTitleSnapshot String? @db.VarChar(255)
|
||||
sourceSnippetSnapshot String? @db.Text
|
||||
orderIndex Int @default(0)
|
||||
status String @default("active") @db.VarChar(32)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
knowledgeBase KnowledgeBase @relation(fields: [knowledgeBaseId], references: [id])
|
||||
@ -231,25 +240,36 @@ model UploadedFile {
|
||||
bucket String? @db.VarChar(100)
|
||||
sizeBytes BigInt @default(0)
|
||||
checksum String? @db.VarChar(255)
|
||||
sha256 String? @db.VarChar(64)
|
||||
purpose String? @db.VarChar(32)
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
sources KnowledgeSource[]
|
||||
|
||||
@@index([userId])
|
||||
@@index([objectKey])
|
||||
@@index([sha256])
|
||||
}
|
||||
|
||||
model DocumentImport {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
knowledgeBaseId String?
|
||||
sourceId String?
|
||||
fileId String?
|
||||
sourceType String @db.VarChar(32)
|
||||
sourceName String? @db.VarChar(255)
|
||||
sourceUrl String? @db.VarChar(500)
|
||||
rawText String? @db.LongText
|
||||
status String @default("pending") @db.VarChar(32)
|
||||
status String @default("QUEUED") @db.VarChar(32)
|
||||
step String? @db.VarChar(32)
|
||||
progress Int @default(0)
|
||||
workerId String? @db.VarChar(255)
|
||||
retryCount Int @default(0)
|
||||
maxRetries Int @default(3)
|
||||
heartbeatAt DateTime?
|
||||
errorCode String? @db.VarChar(32)
|
||||
errorMessage String? @db.Text
|
||||
resultJson Json?
|
||||
startedAt DateTime?
|
||||
@ -258,9 +278,13 @@ model DocumentImport {
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
source KnowledgeSource? @relation(fields: [sourceId], references: [id])
|
||||
candidates ImportCandidate[]
|
||||
|
||||
@@index([userId])
|
||||
@@index([status])
|
||||
@@index([sourceId])
|
||||
@@index([workerId])
|
||||
}
|
||||
|
||||
model LearningSession {
|
||||
@ -575,3 +599,137 @@ model AppChangelog {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
// ── 知识库新增模型 ──
|
||||
|
||||
model KnowledgeSource {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
knowledgeBaseId String
|
||||
fileId String?
|
||||
type String @default("file") @db.VarChar(32)
|
||||
title String? @db.VarChar(255)
|
||||
originalFilename String? @db.VarChar(255)
|
||||
mimeType String? @db.VarChar(100)
|
||||
sizeBytes BigInt @default(0)
|
||||
textLength Int @default(0)
|
||||
parseStatus String @default("pending") @db.VarChar(32)
|
||||
indexStatus String @default("pending") @db.VarChar(32)
|
||||
learningStatus String @default("pending") @db.VarChar(32)
|
||||
parsedObjectKey String? @db.VarChar(500)
|
||||
metadataObjectKey String? @db.VarChar(500)
|
||||
originalObjectKey String? @db.VarChar(500)
|
||||
version Int @default(1)
|
||||
parentSourceId String?
|
||||
replacedBySourceId String?
|
||||
errorCode String? @db.VarChar(32)
|
||||
errorMessage String? @db.Text
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
knowledgeBase KnowledgeBase @relation(fields: [knowledgeBaseId], references: [id])
|
||||
file UploadedFile? @relation(fields: [fileId], references: [id])
|
||||
chunks KnowledgeChunk[]
|
||||
imports DocumentImport[]
|
||||
candidates ImportCandidate[]
|
||||
|
||||
@@index([userId])
|
||||
@@index([knowledgeBaseId])
|
||||
@@index([fileId])
|
||||
@@index([parseStatus])
|
||||
@@index([indexStatus])
|
||||
}
|
||||
|
||||
model KnowledgeChunk {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
knowledgeBaseId String
|
||||
sourceId String
|
||||
content String @db.LongText
|
||||
chunkIndex Int
|
||||
pageNumber Int?
|
||||
sectionTitle String? @db.VarChar(500)
|
||||
tokenCount Int @default(0)
|
||||
externalVectorId String? @db.VarChar(255)
|
||||
embeddingModel String? @db.VarChar(100)
|
||||
embeddingStatus String @default("pending") @db.VarChar(32)
|
||||
metadataJson Json?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
deletedAt DateTime?
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
knowledgeBase KnowledgeBase @relation(fields: [knowledgeBaseId], references: [id])
|
||||
source KnowledgeSource @relation(fields: [sourceId], references: [id])
|
||||
|
||||
@@index([userId])
|
||||
@@index([sourceId])
|
||||
@@index([knowledgeBaseId])
|
||||
@@index([externalVectorId])
|
||||
}
|
||||
|
||||
model ImportCandidate {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
knowledgeBaseId String
|
||||
sourceId String
|
||||
importId String
|
||||
title String @db.VarChar(255)
|
||||
summary String? @db.Text
|
||||
content String? @db.LongText
|
||||
tagsJson Json?
|
||||
recallQuestionsJson Json?
|
||||
sourceTextSnippet String? @db.Text
|
||||
sourceChunkIds Json?
|
||||
confidence Decimal @default(0) @db.Decimal(4, 3)
|
||||
difficulty String? @db.VarChar(16)
|
||||
orderIndex Int @default(0)
|
||||
status String @default("PENDING") @db.VarChar(16)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
knowledgeBase KnowledgeBase @relation(fields: [knowledgeBaseId], references: [id])
|
||||
source KnowledgeSource @relation(fields: [sourceId], references: [id])
|
||||
import DocumentImport @relation(fields: [importId], references: [id])
|
||||
|
||||
@@index([userId])
|
||||
@@index([sourceId])
|
||||
@@index([importId])
|
||||
@@index([status])
|
||||
}
|
||||
|
||||
model BackupJob {
|
||||
id String @id @default(cuid())
|
||||
type String @db.VarChar(16)
|
||||
status String @default("RUNNING") @db.VarChar(16)
|
||||
localPath String? @db.VarChar(500)
|
||||
cosObjectKey String? @db.VarChar(500)
|
||||
fileSizeBytes BigInt @default(0)
|
||||
startedAt DateTime @default(now())
|
||||
completedAt DateTime?
|
||||
errorMessage String? @db.Text
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model MembershipPlan {
|
||||
id String @id @default(cuid())
|
||||
code String @unique @db.VarChar(32)
|
||||
name String @db.VarChar(100)
|
||||
priceMonthly Int @default(0)
|
||||
priceYearly Int @default(0)
|
||||
maxKnowledgeBases Int @default(1)
|
||||
maxStorageBytes BigInt @default(0)
|
||||
maxFileSizeBytes BigInt @default(0)
|
||||
monthlyOcrPages Int @default(0)
|
||||
monthlyVisionPages Int @default(0)
|
||||
monthlyChatCount Int @default(0)
|
||||
monthlyAiAnalysisCount Int @default(0)
|
||||
monthlyRecallCount Int @default(0)
|
||||
monthlyCardGenCount Int @default(0)
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user