| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
CREATE TABLE webhook_events ( |
| 5 |
id UUID PRIMARY KEY DEFAULT gen_random_uuid(), |
| 6 |
source TEXT NOT NULL, |
| 7 |
event_type TEXT NOT NULL, |
| 8 |
payload TEXT NOT NULL, |
| 9 |
signature TEXT, |
| 10 |
status TEXT NOT NULL DEFAULT 'failed' CHECK (status IN ('failed', 'retrying', 'dead')), |
| 11 |
attempts INT NOT NULL DEFAULT 0, |
| 12 |
last_error TEXT, |
| 13 |
next_retry_at TIMESTAMPTZ NOT NULL DEFAULT NOW() + INTERVAL '60 seconds', |
| 14 |
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW() |
| 15 |
); |
| 16 |
|
| 17 |
CREATE INDEX idx_webhook_events_retry ON webhook_events (next_retry_at) WHERE status IN ('failed', 'retrying'); |
| 18 |
|