CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
0056_webhook_deliveries.sql
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 8405c43 | 1 | -- Reliable webhook delivery — retry queue + dead-letter. |
| 2 | -- | |
| 3 | -- Replaces the single-shot fire-and-forget loop in src/routes/webhooks.tsx | |
| 4 | -- with a durable pending-row pattern. `fireWebhooks()` now inserts one row | |
| 5 | -- per (hook, event) into `webhook_deliveries` with status='pending' and | |
| 6 | -- next_attempt_at=now(); the background worker in | |
| 7 | -- src/lib/webhook-delivery.ts claims rows, attempts the POST, and on | |
| 8 | -- failure reschedules with exponential backoff (30s, 2m, 10m, 1h, 6h). | |
| 9 | -- After 6 attempts a row transitions to status='dead' and stays for | |
| 10 | -- observability — operators can re-queue manually or purge. | |
| 11 | ||
| 12 | CREATE TABLE IF NOT EXISTS webhook_deliveries ( | |
| 13 | id uuid PRIMARY KEY DEFAULT gen_random_uuid(), | |
| 14 | webhook_id uuid NOT NULL REFERENCES webhooks(id) ON DELETE CASCADE, | |
| 15 | event text NOT NULL, | |
| 16 | payload text NOT NULL, | |
| 17 | signature text NOT NULL, | |
| 18 | attempt_count integer NOT NULL DEFAULT 0, | |
| 19 | next_attempt_at timestamptz, | |
| 20 | status text NOT NULL DEFAULT 'pending', -- pending | succeeded | failed | dead | |
| 21 | last_status_code integer, | |
| 22 | last_error text, | |
| 23 | last_attempted_at timestamptz, | |
| 24 | succeeded_at timestamptz, | |
| 25 | created_at timestamptz NOT NULL DEFAULT now() | |
| 26 | ); | |
| 27 | ||
| 28 | CREATE INDEX IF NOT EXISTS idx_webhook_deliveries_next_attempt | |
| 29 | ON webhook_deliveries (next_attempt_at) WHERE status = 'pending'; | |
| 30 | ||
| 31 | CREATE INDEX IF NOT EXISTS idx_webhook_deliveries_webhook_id | |
| 32 | ON webhook_deliveries (webhook_id, created_at DESC); |