Added basic prisma schema

This commit is contained in:
lucast committed 2026-11-20 09:46:10 +01:00
1 parent df5a977608
commit a1c874c153
9 files changed
+140 -9

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
model CarBrand {
id Int @id @default(autoincrement())
name String
carModels CarModel[]
}
model CarModel {
id Int @id @default(autoincrement())
name String
carBrandId Int
brand CarBrand @relation(fields: [carBrandId], references: [id])
cars Car[]
}
model Car {
id Int @id @default(autoincrement())
licensePlate String
productionYear Int
carModelId Int
model CarModel @relation(fields: [carModelId], references: [id])
customerId Int
customer Customer @relation(fields: [customerId], references: [id])
workOrders WorkOrder[]
}
+9
View File
@@ -0,0 +1,9 @@
model Customer {
id Int @id @default(autoincrement())
name String
email String
phone String
cars Car[]
}
+8
View File
@@ -0,0 +1,8 @@
model Invoice {
workOrderId Int @unique
workOrder WorkOrder @relation(fields: [workOrderId], references: [id])
total Int
paidDate DateTime?
}
+27
View File
@@ -0,0 +1,27 @@
model Mechanic {
id Int @id @default(autoincrement())
name String
hourlyRate Int
skills MechanicToSkill[]
workOrders WorkOrderToMechanic[]
}
model MechanicToSkill {
mechanicId Int
mechanic Mechanic @relation(fields: [mechanicId], references: [id])
skillId Int
skill MechanicSkill @relation(fields: [skillId], references: [id])
@@id([mechanicId, skillId])
}
model MechanicSkill {
id Int @id @default(autoincrement())
name String
mechanics MechanicToSkill[]
}
+29
View File
@@ -0,0 +1,29 @@
model SparePart {
id Int @id @default(autoincrement())
name String
partNumber String
supplierId Int
supplier Supplier @relation(fields: [supplierId], references: [id])
workOrderToSpareParts WorkOrderToSparePart[]
}
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 Int
pricePerUnit Int
@@id([sparePartId, workOrderId])
}
+34
View File
@@ -0,0 +1,34 @@
enum WorkOrderStatus {
OPEN
IN_PROGRESS
DONE
}
model WorkOrder {
id Int @id @default(autoincrement())
currentMileage Int
problem String
carId Int
car Car @relation(fields: [carId], references: [id])
mechanics WorkOrderToMechanic[]
sparePart WorkOrderToSparePart[]
invoice Invoice?
status WorkOrderStatus @default(OPEN)
createdAt DateTime @default(now())
}
model WorkOrderToMechanic {
mechanicId Int
mechanic Mechanic @relation(fields: [mechanicId], references: [id])
workOrderId Int
workOrder WorkOrder @relation(fields: [workOrderId], references: [id])
minutesWorked Int
@@id([mechanicId, workOrderId])
}