Last active
February 19, 2025 06:16
-
-
Save Anwar05108/815cc419cd772ed5732374151c254e78 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
generator client { | |
provider = "prisma-client-js" | |
} | |
datasource db { | |
provider = "postgresql" | |
url = env("DATABASE_URL") | |
directUrl = env("DIRECT_URL") | |
} | |
model User { | |
id String @id @default(uuid()) | |
name String | |
password String | |
email String @unique | |
address String | |
contactNum String | |
role Role | |
appointmentContacts AppointmentContact[] | |
appointmentServiceAdvisor AppointmentServiceAdvisor[] | |
appointmentTechnician AppointmentTechnician[] | |
customers Customer? @relation("CustomerUser") | |
employees Employee? @relation("EmployeeUser") | |
EstimateCustomer EstimateCustomer[] | |
estimateCustomer EstimateCustomerAuthorization[] @relation("CustomerAuthorizations") | |
providerAuthorization EstimateCustomerAuthorization[] @relation("ProviderAuthorizations") | |
estimateInspectionInspector EstimateInspectionInspector[] | |
estimateTechnician EstimateTechnician[] | |
vehicles Vehicle[] @relation("VehicleOwner") | |
} | |
model Employee { | |
employeeId String @unique | |
employeeRole String | |
employeeSubRole String | |
employee User @relation("EmployeeUser", fields: [employeeId], references: [id], map: "employee_employeeId_fkey") | |
} | |
model Customer { | |
customerId String @unique | |
preferredCommunicationType String | |
customer User @relation("CustomerUser", fields: [customerId], references: [id], map: "customer_customerId_fkey") | |
} | |
model Concern { | |
code String @id @unique | |
title String | |
description String | |
type String @default("Concern") | |
inspections ConcernInspection[] | |
services ConcernService[] | |
estimates EstimateConcern[] | |
} | |
model Vehicle { | |
id String @id @default(uuid()) | |
make String | |
model String | |
year Int | |
color String | |
vin String | |
numberPlate String @unique | |
mileage Int | |
condition String | |
ownerId String | |
estimates EstimateVehicle[] | |
owner User @relation("VehicleOwner", fields: [ownerId], references: [id]) | |
} | |
model Service { | |
code String @id @unique @default(uuid()) | |
title String | |
description String | |
type String @default("Service") | |
appointmentServices AppointmentService[] | |
concerns ConcernService[] | |
estimates EstimateService[] | |
estimateServiceLabour EstimateServiceLabour[] | |
estimateServiceParts EstimateServiceParts[] | |
inspectionItemGenerals InspectionItemGeneralService[] | |
inspectionItemTires InspectionItemTireService[] | |
ServiceInspection ServiceInspection[] | |
serviceLabours ServiceLabour[] @relation("ServiceToLabour") | |
serviceParts ServiceParts[] | |
referencingServices ServiceService[] @relation("RelatedToService") | |
relatedServices ServiceService[] @relation("ServiceRelated") | |
} | |
model Labour { | |
labourId String @id @default(uuid()) | |
name String | |
ratePerHour Float | |
estimateServiceLabour EstimateServiceLabour[] | |
serviceLabours ServiceLabour[] @relation("LabourToService") | |
} | |
model ServiceLabour { | |
id String @id @default(uuid()) | |
serviceCode String | |
labourId String | |
hours Float @default(1.0) | |
labour Labour @relation("LabourToService", fields: [labourId], references: [labourId], onDelete: Cascade) | |
service Service @relation("ServiceToLabour", fields: [serviceCode], references: [code], onDelete: Cascade) | |
@@unique([serviceCode, labourId]) | |
} | |
model ConcernService { | |
concernCode String | |
serviceCode String | |
type Type | |
concern Concern @relation(fields: [concernCode], references: [code]) | |
service Service @relation(fields: [serviceCode], references: [code]) | |
@@id([concernCode, serviceCode]) | |
} | |
model Parts { | |
partId String @id @default(uuid()) | |
name String | |
unitPrice Float | |
provider String | |
installationHours Float | |
EstimateServiceParts EstimateServiceParts[] | |
serviceParts ServiceParts[] | |
} | |
model ServiceParts { | |
id String @id @default(uuid()) | |
serviceId String | |
partId String | |
quantity Int | |
part Parts @relation(fields: [partId], references: [partId], map: "fk_service_parts_part") | |
service Service @relation(fields: [serviceId], references: [code], map: "fk_service_parts_service") | |
} | |
model ServiceService { | |
id String @id @default(uuid()) | |
serviceId String | |
relatedServiceId String | |
recommended Boolean @default(false) | |
required Boolean @default(false) | |
relatedService Service @relation("RelatedToService", fields: [relatedServiceId], references: [code], map: "fk_service_service_related") | |
service Service @relation("ServiceRelated", fields: [serviceId], references: [code], map: "fk_service_service_main") | |
} | |
model InspectionItemGeneral { | |
code String @id @unique | |
name String | |
customNote String | |
type String @default("General") | |
services InspectionItemGeneralService[] | |
maps InspectionMAP[] | |
problems InspectionProblem[] | |
solutions InspectionSolutionGeneral[] | |
InspectionItemGeneralForInspection InspectionItemGeneralForInspection[] | |
} | |
model InspectionItemGeneralService { | |
inspectionItemGeneralCode String | |
serviceCode String | |
type Type | |
recommended Boolean @default(false) | |
required Boolean @default(false) | |
inspectionItemGeneral InspectionItemGeneral @relation(fields: [inspectionItemGeneralCode], references: [code]) | |
service Service @relation(fields: [serviceCode], references: [code]) | |
@@id([inspectionItemGeneralCode, serviceCode]) | |
} | |
model InspectionProblem { | |
id String @id @default(uuid()) | |
name String | |
inspectionId String | |
color String | |
inspection InspectionItemGeneral @relation(fields: [inspectionId], references: [code]) | |
} | |
model InspectionMAP { | |
id String @id @default(uuid()) | |
name String | |
inspectionId String | |
inspection InspectionItemGeneral @relation(fields: [inspectionId], references: [code]) | |
} | |
model InspectionSolutionGeneral { | |
id String @id @default(uuid()) | |
name String | |
inspectionId String | |
inspection InspectionItemGeneral @relation(fields: [inspectionId], references: [code]) | |
} | |
model InspectionItemTire { | |
code String @id @unique | |
name String | |
customNote String | |
psiBefore String | |
type String @default("Tire") | |
services InspectionItemTireService[] | |
solutions InspectionSolutionTire[] | |
tireStatuses InspectionTireStatus[] | |
treadDepths InspectionTreadDepth[] | |
InspectionItemTireForInspection InspectionItemTireForInspection[] | |
} | |
model InspectionItemTireService { | |
inspectionItemTireCode String | |
serviceCode String | |
type Type | |
recommended Boolean @default(false) | |
required Boolean @default(false) | |
inspectionItemTire InspectionItemTire @relation(fields: [inspectionItemTireCode], references: [code]) | |
service Service @relation(fields: [serviceCode], references: [code]) | |
@@id([inspectionItemTireCode, serviceCode]) | |
} | |
model InspectionTireStatus { | |
id String @id @default(uuid()) | |
name String | |
color String | |
inspectionId String | |
inspection InspectionItemTire @relation(fields: [inspectionId], references: [code]) | |
} | |
model InspectionTreadDepth { | |
id String @id @default(uuid()) | |
name String | |
inspectionId String | |
color String @default("green") | |
inspection InspectionItemTire @relation(fields: [inspectionId], references: [code]) | |
} | |
model InspectionSolutionTire { | |
id String @id @default(uuid()) | |
name String | |
inspectionId String | |
inspection InspectionItemTire @relation(fields: [inspectionId], references: [code]) | |
} | |
model Inspection { | |
code String @id @unique | |
title String | |
description String | |
type String @default("Inspection") | |
concerns ConcernInspection[] | |
estimates EstimateInspection[] | |
estimateInspectionHoursForInspection EstimateInspectionHoursForInspection[] | |
InspectionHoursForInspection InspectionHoursForInspection[] | |
ServiceInspection ServiceInspection[] | |
InspectionItemGeneralForInspection InspectionItemGeneralForInspection[] | |
InspectionItemTireForInspection InspectionItemTireForInspection[] | |
} | |
model InspectionHours { | |
id String @id @default(uuid()) | |
inspectionHourlyRate Float? @default(0.0) | |
inspectionHours Float? @default(0.0) | |
estimateInspectionHoursForInspection EstimateInspectionHoursForInspection[] | |
InspectionHoursForInspection InspectionHoursForInspection[] | |
} | |
model InspectionHoursForInspection { | |
id String @id @default(uuid()) | |
inspectionId String | |
inspectionHoursId String | |
InspectionHours InspectionHours @relation(fields: [inspectionHoursId], references: [id]) | |
Inspection Inspection @relation(fields: [inspectionId], references: [code]) | |
} | |
model ConcernInspection { | |
concernCode String | |
inspectionCode String | |
type Type | |
concern Concern @relation(fields: [concernCode], references: [code]) | |
inspection Inspection @relation(fields: [inspectionCode], references: [code]) | |
@@id([concernCode, inspectionCode]) | |
} | |
model InspectionItemsForInpection { | |
id String @id @default(uuid()) | |
inspectionCode String | |
inspectionItemCode String | |
inspectionItemType String | |
} | |
model InspectionGroup { | |
code String @id @unique | |
name String | |
description String | |
} | |
model InspectionGroupInspection { | |
inspectionCode String | |
inspectionGroupCode String | |
@@id([inspectionCode, inspectionGroupCode]) | |
} | |
model InspectionGroupLabour { | |
inspectionGroupCode String | |
labourName String | |
labourRatePerHour Float | |
@@id([inspectionGroupCode, labourName]) | |
} | |
model Estimate { | |
code String @unique | |
title String | |
description String | |
inspectionTotalHours String? | |
labourTotalHours String? | |
totalHours String? | |
labourTotalAmount Float? | |
partsTotalAmount Float? | |
inspectionTotalAmount Float? | |
totalAmount Float? | |
status EstimateStatus @default(Pending) | |
type EstimateType @default(Estimate) | |
concerns EstimateConcern[] | |
customers EstimateCustomer[] | |
estimateAuthorization EstimateCustomerAuthorization[] | |
inspections EstimateInspection[] | |
estimateInspectionHoursForInspection EstimateInspectionHoursForInspection[] | |
estimateInspectionInspector EstimateInspectionInspector[] | |
services EstimateService[] | |
estimateServiceLabour EstimateServiceLabour[] | |
estimateServiceParts EstimateServiceParts[] | |
estimateTechnician EstimateTechnician[] | |
vehicle EstimateVehicle[] | |
} | |
model EstimateCustomer { | |
estimateCode String | |
userId String | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
user User @relation(fields: [userId], references: [id]) | |
@@id([estimateCode, userId]) | |
} | |
model EstimateVehicle { | |
estimateCode String | |
vehicleId String | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
vehicle Vehicle @relation(fields: [vehicleId], references: [id]) | |
@@id([estimateCode, vehicleId]) | |
} | |
model EstimateConcern { | |
estimateCode String | |
concernCode String | |
concern Concern @relation(fields: [concernCode], references: [code]) | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
@@id([estimateCode, concernCode]) | |
} | |
model EstimateInspection { | |
estimateCode String | |
inspectionCode String | |
stage Stage | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
inspection Inspection @relation(fields: [inspectionCode], references: [code]) | |
@@id([estimateCode, inspectionCode]) | |
} | |
model EstimateService { | |
estimateCode String | |
serviceCode String | |
stage Stage | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
service Service @relation(fields: [serviceCode], references: [code]) | |
@@id([estimateCode, serviceCode]) | |
} | |
model EstimateCustomerAuthorization { | |
estimateCode String | |
customerId String | |
providerId String | |
authorizationStatus AuthorizationStatus @default(Incomplete) | |
authorizationMedium AuthorizationMedium | |
createdAt DateTime @default(now()) | |
id String @id @default(uuid()) | |
customer User @relation("CustomerAuthorizations", fields: [customerId], references: [id]) | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
provider User @relation("ProviderAuthorizations", fields: [providerId], references: [id]) | |
} | |
model EstimateServiceParts { | |
id String @id @default(uuid()) | |
estimateCode String | |
serviceCode String | |
partId String | |
totalUnit Int | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
part Parts @relation(fields: [partId], references: [partId]) | |
service Service @relation(fields: [serviceCode], references: [code]) | |
} | |
model EstimateServiceLabour { | |
id String @id @default(uuid()) | |
estimateCode String | |
serviceCode String | |
labourId String | |
requiredHours Float @default(1.0) | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
labour Labour @relation(fields: [labourId], references: [labourId]) | |
service Service @relation(fields: [serviceCode], references: [code]) | |
} | |
model EstimateTechnician { | |
id String @id @default(uuid()) | |
estimateCode String | |
technicianId String | |
percentage String | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
technician User @relation(fields: [technicianId], references: [id]) | |
} | |
model EstimateInspectionHoursForInspection { | |
id String @id @default(uuid()) | |
estimateCode String | |
inspectionCode String | |
inspectionHoursId String | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
inspection Inspection @relation(fields: [inspectionCode], references: [code]) | |
inspectionHours InspectionHours @relation(fields: [inspectionHoursId], references: [id]) | |
} | |
model EstimateInspectionInspector { | |
id String @id @default(uuid()) | |
estimateCode String | |
inspectorId String | |
percentage String | |
estimate Estimate @relation(fields: [estimateCode], references: [code]) | |
inspector User @relation(fields: [inspectorId], references: [id]) | |
} | |
model Appointment { | |
id String @id @default(uuid()) | |
startHour String | |
endHour String | |
suggestedHour String? | |
duration String | |
odometer String | |
note String? | |
scheduled DateTime | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
contacts AppointmentContact[] | |
services AppointmentService[] | |
serviceAdvisor AppointmentServiceAdvisor[] | |
technician AppointmentTechnician[] | |
} | |
model AppointmentService { | |
appointmentID String | |
serviceCode String | |
appointment Appointment @relation(fields: [appointmentID], references: [id]) | |
service Service @relation(fields: [serviceCode], references: [code]) | |
@@id([appointmentID, serviceCode]) | |
} | |
model AppointmentContact { | |
appointmentID String | |
contactId String | |
appointment Appointment @relation(fields: [appointmentID], references: [id]) | |
contact User @relation(fields: [contactId], references: [id]) | |
@@id([appointmentID, contactId]) | |
} | |
model AppointmentServiceAdvisor { | |
appointmentID String | |
serviceAdvisorId String | |
appointment Appointment @relation(fields: [appointmentID], references: [id]) | |
serviceAdvisor User @relation(fields: [serviceAdvisorId], references: [id]) | |
@@id([appointmentID, serviceAdvisorId]) | |
} | |
model AppointmentTechnician { | |
appointmentID String | |
technicianId String | |
appointment Appointment @relation(fields: [appointmentID], references: [id]) | |
technician User @relation(fields: [technicianId], references: [id]) | |
@@id([appointmentID, technicianId]) | |
} | |
model technician { | |
id String @id | |
level String @default("1") | |
} | |
model technicianConcern { | |
id String @id | |
concernCode String | |
technicianID String | |
currentWorkStatus workStatus @default(PENDING) | |
@@unique([concernCode, technicianID]) | |
} | |
model technicianInspectionItem { | |
id String @id | |
inspectionItemCode String | |
technicianID String | |
currentWorkStatus workStatus @default(PENDING) | |
inspectionItemType String @default("General") | |
@@unique([inspectionItemCode, technicianID]) | |
} | |
model technicianService { | |
id String @id | |
serviceId String | |
technicianID String | |
currentWorkStatus workStatus @default(PENDING) | |
@@unique([serviceId, technicianID]) | |
} | |
model ServiceInspection { | |
id String @id | |
serviceCode String | |
inspectionCode String | |
type Type | |
Inspection Inspection @relation(fields: [inspectionCode], references: [code]) | |
Service Service @relation(fields: [serviceCode], references: [code]) | |
} | |
enum Role { | |
admin | |
storeManager | |
technician | |
Employee | |
Customer | |
serviceAdvisor | |
} | |
enum Status { | |
Available | |
Unavailable | |
} | |
enum Stage { | |
Accept | |
Deferred | |
} | |
enum Type { | |
Recommended | |
Required | |
} | |
enum AuthorizationStatus { | |
Complete | |
Incomplete | |
} | |
enum AuthorizationMedium { | |
SMS | |
Call | |
} | |
enum workStatus { | |
PENDING | |
IN_PROGRESS | |
COMPLETED | |
CANCELLED | |
} | |
enum EstimateStatus { | |
Pending | |
Approved | |
Rejected | |
Report_Generated | |
} | |
enum EstimateType { | |
Estimate | |
WorkOrder | |
} | |
model InspectionItemGeneralForInspection{ | |
id String @default(uuid()) | |
inspectionItemCode String | |
inspectionCode String | |
type String @default("General") | |
Inspection Inspection @relation(fields: [inspectionCode], references: [code]) | |
InspectionItemGeneral InspectionItemGeneral @relation(fields: [inspectionItemCode], references: [code]) | |
@@unique([inspectionItemCode, inspectionCode]) | |
} | |
model InspectionItemTireForInspection{ | |
id String @default(uuid()) | |
inspectionItemCode String | |
inspectionCode String | |
type String @default("Tire") | |
Inspection Inspection @relation(fields: [inspectionCode], references: [code]) | |
InspectionItemTire InspectionItemTire @relation(fields: [inspectionItemCode], references: [code]) | |
@@unique([inspectionItemCode, inspectionCode]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment