condition-marks.prisma 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /// A mark on the vehicle's condition map: a dent, a scratch, a chip, drawn
  2. /// on a line drawing of the car by tapping where it is.
  3. ///
  4. /// Marks belong to the vehicle, not to the sheet they were drawn on. An
  5. /// inspection or a work order records new ones; the next visit starts with
  6. /// the ones still there, greyed, and either confirms them or clears them as
  7. /// repaired. That is what makes "new since last time" a fact rather than an
  8. /// argument. The sheet a mark was drawn on is kept for the print, and lets
  9. /// go of the mark rather than taking it with it when the sheet is deleted.
  10. model ConditionMark {
  11. id String @id @default(cuid())
  12. organizationId String
  13. organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
  14. vehicleId String
  15. vehicle Vehicle @relation(fields: [vehicleId], references: [id], onDelete: Cascade)
  16. /// Where it was recorded: the inspection check or the work order's drop-off.
  17. inspectionId String?
  18. inspection Inspection? @relation(fields: [inspectionId], references: [id], onDelete: SetNull)
  19. inspectionItemId String?
  20. inspectionItem InspectionItem? @relation(fields: [inspectionItemId], references: [id], onDelete: SetNull)
  21. serviceRecordId String?
  22. serviceRecord ServiceRecord? @relation(fields: [serviceRecordId], references: [id], onDelete: SetNull)
  23. /// Which drawing it sits on, so a body type changed later cannot move it.
  24. bodyType String
  25. /// top | left | right | front | rear
  26. view String
  27. /// The named panel the tap landed on; see condition-map/Lib/drawingTypes.ts.
  28. panel String
  29. /// Position as a fraction of the view's box, 0..1 from the top-left.
  30. x Float
  31. y Float
  32. /// dent | scratch | chip | crack | rust | paint | previous_repair | missing
  33. kind String
  34. /// minor | major
  35. severity String @default("minor")
  36. note String?
  37. imageUrls String[] @default([])
  38. recordedAt DateTime @default(now())
  39. recordedById String?
  40. recordedBy User? @relation("ConditionMarkRecordedBy", fields: [recordedById], references: [id], onDelete: SetNull)
  41. /// Set when a later visit found the damage gone. The mark stays as history
  42. /// and stops printing as current.
  43. resolvedAt DateTime?
  44. resolvedById String?
  45. resolvedBy User? @relation("ConditionMarkResolvedBy", fields: [resolvedById], references: [id], onDelete: SetNull)
  46. createdAt DateTime @default(now())
  47. updatedAt DateTime @updatedAt
  48. @@index([vehicleId])
  49. @@index([inspectionId])
  50. @@index([inspectionItemId])
  51. @@index([serviceRecordId])
  52. @@index([organizationId])
  53. @@map("condition_marks")
  54. }