closures.prisma 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /// A day, or run of days, the whole workshop is closed, entered by hand: a
  2. /// shutdown week, a staff day, the afternoon of Christmas Eve. Public holidays
  3. /// from the workshop's country and holiday calendars are not stored here; they
  4. /// are read from settings and joined with these when a calendar is built.
  5. model WorkshopClosure {
  6. id String @id @default(cuid())
  7. name String
  8. /// First and last closed day, both included, as dates on the workshop's
  9. /// own calendar. Kept as dates, not instants, so a time zone change cannot
  10. /// move a holiday.
  11. startDate DateTime @db.Date
  12. endDate DateTime @db.Date
  13. /// "HH:mm" the closure begins on its first day. Null closes the whole day.
  14. startTime String?
  15. /// "HH:mm" the closure ends on its last day. Null keeps it closed to the
  16. /// end of that day.
  17. endTime String?
  18. /// Closed on the same dates every year (a national day, a staff holiday).
  19. repeatsYearly Boolean @default(false)
  20. organizationId String
  21. organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
  22. createdAt DateTime @default(now())
  23. updatedAt DateTime @updatedAt
  24. @@index([organizationId, startDate])
  25. @@map("workshop_closures")
  26. }
  27. /// Time a technician is away: holiday, sick leave, a course. The work board,
  28. /// the scheduler and online booking read it so nobody is booked while away.
  29. model TechnicianAbsence {
  30. id String @id @default(cuid())
  31. /// First and last day away, both included, on the workshop's calendar.
  32. startDate DateTime @db.Date
  33. endDate DateTime @db.Date
  34. /// "HH:mm" the absence begins on its first day. Null is the whole day.
  35. startTime String?
  36. /// "HH:mm" it ends on its last day. Null is to the end of that day.
  37. endTime String?
  38. /// holiday, sick, training or other.
  39. reason String @default("holiday")
  40. note String?
  41. technicianId String
  42. technician Technician @relation(fields: [technicianId], references: [id], onDelete: Cascade)
  43. organizationId String
  44. organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
  45. createdAt DateTime @default(now())
  46. updatedAt DateTime @updatedAt
  47. @@index([organizationId, startDate])
  48. @@index([technicianId])
  49. @@map("technician_absences")
  50. }