reports.prisma 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. model StatusReport {
  2. id String @id @default(cuid())
  3. title String?
  4. message String? @db.Text
  5. videoUrl String?
  6. videoFileName String?
  7. publicToken String @unique
  8. status String @default("draft") // draft | published | sent | viewed
  9. sentVia String? // email, sms, telegram (comma-separated)
  10. sentAt DateTime?
  11. viewedAt DateTime?
  12. customerFeedback String? @db.Text
  13. feedbackAt DateTime?
  14. expiresAt DateTime?
  15. createdAt DateTime @default(now())
  16. updatedAt DateTime @updatedAt
  17. serviceRecordId String
  18. serviceRecord ServiceRecord @relation(fields: [serviceRecordId], references: [id], onDelete: Cascade)
  19. organizationId String
  20. organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
  21. technicianId String?
  22. technician Technician? @relation(fields: [technicianId], references: [id], onDelete: SetNull)
  23. @@index([serviceRecordId])
  24. @@index([organizationId])
  25. @@index([publicToken])
  26. @@index([expiresAt])
  27. @@map("status_reports")
  28. }
  29. model ReportSchedule {
  30. id String @id @default(cuid())
  31. name String @default("Scheduled Report")
  32. frequency String // "daily" | "weekly" | "monthly" etc.
  33. dateRange String @default("last30d") // "last1d" | "last7d" | "last30d" | "ytd" | "allTime" etc.
  34. sections String // JSON array of section keys
  35. recipients String // JSON array of user IDs
  36. nextRunDate DateTime
  37. endDate DateTime?
  38. isActive Boolean @default(true)
  39. lastRunAt DateTime?
  40. runCount Int @default(0)
  41. createdAt DateTime @default(now())
  42. updatedAt DateTime @updatedAt
  43. organizationId String
  44. organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
  45. createdById String
  46. @@index([organizationId])
  47. @@index([nextRunDate, isActive])
  48. @@map("report_schedules")
  49. }