Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions prisma/migrations/20260428000000_drop_alert_webhook/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-- Drop the legacy AlertWebhook model in favor of NotificationChannel(type=webhook).
--
-- The NotificationChannel infrastructure (drivers, DeliveryAttempt tracking,
-- AlertRuleChannel routing) fully subsumes AlertWebhook's functionality and
-- adds delivery tracking, retries, and per-rule routing that AlertWebhook
-- never had.
--
-- Existing AlertWebhook rows MUST be migrated to NotificationChannel(type=webhook)
-- before this migration is applied (operator action — no automated copy because
-- hmacSecret is plaintext and config encryption strategy is decided per-deploy).

-- Drop the AlertWebhook table (CASCADE drops the FK from Environment too).
DROP TABLE IF EXISTS "AlertWebhook" CASCADE;

-- Drop the dangling webhookId column on DeliveryAttempt (only legacy_webhook
-- rows used it; all DeliveryAttempts now route via channelId).
ALTER TABLE "DeliveryAttempt" DROP COLUMN IF EXISTS "webhookId";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve retryability of existing webhook delivery attempts

Dropping DeliveryAttempt.webhookId here makes pre-migration failed webhook attempts unrecoverable: historical rows created via trackWebhookDelivery only have webhookId (with channelId = null), but the new retry paths now require channelId (retryDelivery throws on missing channel and RetryService skips). After this migration, those existing failures can still appear in failed-delivery lists but cannot actually be retried. Please migrate or clean up legacy DeliveryAttempt rows (or backfill a retry target) before removing the column.

Useful? React with 👍 / 👎.

18 changes: 1 addition & 17 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ model Environment {
gitWebhookSecret String? // HMAC secret for validating incoming git webhooks
requireDeployApproval Boolean @default(false)
alertRules AlertRule[]
alertWebhooks AlertWebhook[]
notificationChannels NotificationChannel[]
serviceAccounts ServiceAccount[]
deployRequests DeployRequest[]
Expand Down Expand Up @@ -1012,20 +1011,6 @@ model AlertRule {
@@index([teamId])
}

model AlertWebhook {
id String @id @default(cuid())
environmentId String
environment Environment @relation(fields: [environmentId], references: [id], onDelete: Cascade)
url String
headers Json?
hmacSecret String?
enabled Boolean @default(true)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt

@@index([environmentId])
}

model WebhookEndpoint {
id String @id @default(cuid())
teamId String
Expand Down Expand Up @@ -1106,14 +1091,13 @@ model DeliveryAttempt {
id String @id @default(cuid())
alertEventId String
alertEvent AlertEvent @relation(fields: [alertEventId], references: [id], onDelete: Cascade)
channelType String // 'webhook' | 'slack' | 'email' | 'pagerduty' | 'legacy_webhook'
channelType String // 'webhook' | 'slack' | 'email' | 'pagerduty'
channelName String
status String // 'pending' | 'success' | 'failed'
statusCode Int?
errorMessage String?
attemptNumber Int @default(1)
nextRetryAt DateTime?
webhookId String?
channelId String?
requestedAt DateTime @default(now())
completedAt DateTime?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const CHANNEL_ICONS: Record<string, string> = {
email: "📧",
webhook: "🌐",
pagerduty: "🚨",
legacy_webhook: "🌐",
};

function channelIcon(type: string): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export function FailedDeliveriesSection({ environmentId }: FailedDeliveriesSecti
email: "📧",
webhook: "🌐",
pagerduty: "🚨",
legacy_webhook: "🌐",
};

return (
Expand Down
Loading
Loading