import.prisma 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. /// One run of the spreadsheet importer. Rows it created point back here so
  2. /// the run can be undone, and the mapping is kept so the same source can be
  3. /// imported again without re-mapping.
  4. model ImportBatch {
  5. id String @id @default(cuid())
  6. organizationId String
  7. organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
  8. userId String
  9. /// What the file was: 'spreadsheet', 'vcard', or a preset id such as 'google-contacts'.
  10. source String
  11. /// 'customers' | 'vehicles' | 'services'
  12. entity String
  13. fileName String
  14. /// 'completed' | 'undone'
  15. status String @default("completed")
  16. totalRows Int @default(0)
  17. created Int @default(0)
  18. updated Int @default(0)
  19. skipped Int @default(0)
  20. failed Int @default(0)
  21. mapping Json?
  22. createdAt DateTime @default(now())
  23. undoneAt DateTime?
  24. customers Customer[]
  25. vehicles Vehicle[]
  26. serviceRecords ServiceRecord[]
  27. user User @relation(fields: [userId], references: [id])
  28. inspections Inspection[]
  29. @@index([organizationId, createdAt])
  30. @@map("import_batches")
  31. }