ai.prisma 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. model AiGeneratedMessage {
  2. id String @id @default(cuid())
  3. vehicleId String
  4. type String // "summary" | "common_issues" | etc.
  5. content String
  6. createdAt DateTime @default(now())
  7. updatedAt DateTime @updatedAt
  8. vehicle Vehicle @relation(fields: [vehicleId], references: [id], onDelete: Cascade)
  9. @@unique([vehicleId, type])
  10. @@map("ai_generated_messages")
  11. }
  12. model AiChat {
  13. id String @id @default(cuid())
  14. title String @default("New chat")
  15. createdAt DateTime @default(now())
  16. updatedAt DateTime @updatedAt
  17. userId String
  18. organizationId String
  19. messages AiChatMessage[]
  20. @@index([organizationId, userId, updatedAt(sort: Desc)])
  21. @@map("ai_chats")
  22. }
  23. model AiChatMessage {
  24. id String @id @default(cuid())
  25. role String // "user" | "assistant"
  26. content String
  27. createdAt DateTime @default(now())
  28. chatId String
  29. chat AiChat @relation(fields: [chatId], references: [id], onDelete: Cascade)
  30. @@index([chatId, createdAt])
  31. @@map("ai_chat_messages")
  32. }