Files

34 lines
788 B
Plaintext

model SparePart {
id Int @id @default(autoincrement())
name String
partNumber String
supplierId Int
supplier Supplier @relation(fields: [supplierId], references: [id])
workOrderToSpareParts WorkOrderToSparePart[]
@@unique([supplierId, partNumber])
}
model Supplier {
id Int @id @default(autoincrement())
name String
spareParts SparePart[]
}
model WorkOrderToSparePart {
sparePartId Int
sparePart SparePart @relation(fields: [sparePartId], references: [id])
workOrderId Int
workOrder WorkOrder @relation(fields: [workOrderId], references: [id])
// quantity > 0
quantity Int
// pricePerUnit >= 0
pricePerUnit Int
@@id([sparePartId, workOrderId])
}