4
0

webhooks.prisma 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. model Webhook {
  2. id String @id @default(cuid())
  3. name String
  4. url String
  5. secret String
  6. events String // JSON array of event names; "*" matches all
  7. isActive Boolean @default(true)
  8. description String?
  9. lastTriggeredAt DateTime?
  10. lastSuccessAt DateTime?
  11. lastFailureAt DateTime?
  12. failureCount Int @default(0)
  13. createdAt DateTime @default(now())
  14. updatedAt DateTime @updatedAt
  15. organizationId String
  16. organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
  17. createdById String
  18. deliveries WebhookDelivery[]
  19. @@index([organizationId])
  20. @@index([organizationId, isActive])
  21. @@map("webhooks")
  22. }
  23. model WebhookDelivery {
  24. id String @id @default(cuid())
  25. event String
  26. payload String // JSON-stringified event payload as sent
  27. status String @default("pending") // pending | success | failed | retrying
  28. statusCode Int?
  29. responseBody String?
  30. errorMessage String?
  31. attempt Int @default(0)
  32. maxAttempts Int @default(5)
  33. nextRetryAt DateTime?
  34. deliveredAt DateTime?
  35. durationMs Int?
  36. createdAt DateTime @default(now())
  37. updatedAt DateTime @updatedAt
  38. webhookId String
  39. webhook Webhook @relation(fields: [webhookId], references: [id], onDelete: Cascade)
  40. @@index([webhookId, createdAt(sort: Desc)])
  41. @@index([status, nextRetryAt])
  42. @@map("webhook_deliveries")
  43. }