60f3cd0df9
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).
78 lines
1.8 KiB
Plaintext
78 lines
1.8 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum RequestStatus {
|
|
pending
|
|
completed
|
|
needs_attention
|
|
}
|
|
|
|
enum JobState {
|
|
requested
|
|
matching
|
|
matched
|
|
downloading
|
|
tagging
|
|
imported
|
|
needs_attention
|
|
}
|
|
|
|
model Request {
|
|
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
|
|
artist String
|
|
album String
|
|
path String
|
|
source String
|
|
format String
|
|
qualityClass Int
|
|
importedAt DateTime @default(now())
|
|
|
|
@@unique([artist, album])
|
|
}
|