internal/store/migrations/0005_webhooks.up.sql

f5294b9a1ea2e1f0dc061f05d0ec1968d39d8e6d
gitbay/internal/store/migrations/0005_webhooks.up.sql

25 lines · 1044 bytes

 1CREATE TABLE webhooks (
 2    id         INTEGER PRIMARY KEY,
 3    repo_id    INTEGER NOT NULL REFERENCES repos(id) ON DELETE CASCADE,
 4    url        TEXT NOT NULL,
 5    secret     TEXT NOT NULL DEFAULT '',
 6    events     TEXT NOT NULL DEFAULT '*',
 7    active     INTEGER NOT NULL DEFAULT 1,
 8    created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
 9);
10CREATE INDEX webhooks_repo ON webhooks(repo_id);
11
12CREATE TABLE webhook_deliveries (
13    id              INTEGER PRIMARY KEY,
14    webhook_id      INTEGER NOT NULL REFERENCES webhooks(id) ON DELETE CASCADE,
15    event_id        INTEGER NOT NULL REFERENCES events(id) ON DELETE CASCADE,
16    attempts        INTEGER NOT NULL DEFAULT 0,
17    next_attempt_at TEXT,
18    delivered_at    TEXT,
19    failed_at       TEXT,
20    last_status     INTEGER,
21    last_error      TEXT,
22    created_at      TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now'))
23);
24CREATE INDEX webhook_deliveries_due ON webhook_deliveries(next_attempt_at)
25    WHERE delivered_at IS NULL AND failed_at IS NULL;
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form