| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- model Webhook {
- id String @id @default(cuid())
- name String
- url String
- secret String
- events String // JSON array of event names; "*" matches all
- isActive Boolean @default(true)
- description String?
- lastTriggeredAt DateTime?
- lastSuccessAt DateTime?
- lastFailureAt DateTime?
- failureCount Int @default(0)
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
- organizationId String
- organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
- createdById String
- deliveries WebhookDelivery[]
- @@index([organizationId])
- @@index([organizationId, isActive])
- @@map("webhooks")
- }
- model WebhookDelivery {
- id String @id @default(cuid())
- event String
- payload String // JSON-stringified event payload as sent
- status String @default("pending") // pending | success | failed | retrying
- statusCode Int?
- responseBody String?
- errorMessage String?
- attempt Int @default(0)
- maxAttempts Int @default(5)
- nextRetryAt DateTime?
- deliveredAt DateTime?
- durationMs Int?
- createdAt DateTime @default(now())
- updatedAt DateTime @updatedAt
- webhookId String
- webhook Webhook @relation(fields: [webhookId], references: [id], onDelete: Cascade)
- @@index([webhookId, createdAt(sort: Desc)])
- @@index([status, nextRetryAt])
- @@map("webhook_deliveries")
- }
|