feat: add Candidate and LibraryItem schema
Adds Candidate (per-job download candidates found by the pipeline) and LibraryItem (per-request imported album, deduped on artist+album) tables. LibraryItem.requestId is @unique since Request.libraryItem is a one-to-one back-relation (required for Prisma validation, matching the existing Job.requestId pattern).
This commit is contained in:
+44
-13
@@ -24,23 +24,54 @@ enum JobState {
|
||||
}
|
||||
|
||||
model Request {
|
||||
id String @id @default(cuid())
|
||||
artist String
|
||||
album String
|
||||
status RequestStatus @default(pending)
|
||||
createdAt DateTime @default(now())
|
||||
job Job?
|
||||
id String @id @default(cuid())
|
||||
artist String
|
||||
album String
|
||||
status RequestStatus @default(pending)
|
||||
createdAt DateTime @default(now())
|
||||
job Job?
|
||||
libraryItem LibraryItem?
|
||||
}
|
||||
|
||||
model Job {
|
||||
id String @id @default(cuid())
|
||||
request Request @relation(fields: [requestId], references: [id], onDelete: Cascade)
|
||||
requestId String @unique
|
||||
state JobState @default(requested)
|
||||
currentStage String @default("intake")
|
||||
attempts Int @default(0)
|
||||
error String?
|
||||
claimedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
candidates Candidate[]
|
||||
}
|
||||
|
||||
model Candidate {
|
||||
id String @id @default(cuid())
|
||||
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade)
|
||||
jobId String
|
||||
source String
|
||||
format String
|
||||
qualityClass Int
|
||||
trackCount Int
|
||||
confidence Float
|
||||
sourceRef String
|
||||
chosen Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model LibraryItem {
|
||||
id String @id @default(cuid())
|
||||
request Request @relation(fields: [requestId], references: [id], onDelete: Cascade)
|
||||
requestId String @unique
|
||||
state JobState @default(requested)
|
||||
currentStage String @default("intake")
|
||||
attempts Int @default(0)
|
||||
error String?
|
||||
claimedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
artist String
|
||||
album String
|
||||
path String
|
||||
source String
|
||||
format String
|
||||
qualityClass Int
|
||||
importedAt DateTime @default(now())
|
||||
|
||||
@@unique([artist, album])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user