-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
51 lines (47 loc) · 2.3 KB
/
schema.sql
File metadata and controls
51 lines (47 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
CREATE TABLE guilds (
id TEXT PRIMARY KEY NOT NULL,
banned BOOLEAN NOT NULL DEFAULT FALSE
);
CREATE TABLE webhooks (
id TEXT PRIMARY KEY NOT NULL,
guild_id TEXT NOT NULL REFERENCES guilds(id) ON DELETE CASCADE ON UPDATE CASCADE,
comment TEXT NOT NULL, -- A comment to help identify the webhook
broken BOOLEAN NOT NULL DEFAULT FALSE,
secret TEXT NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_by TEXT NOT NULL,
last_updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
last_updated_by TEXT NOT NULL
);
CREATE TABLE repos (
id TEXT PRIMARY KEY NOT NULL,
guild_id TEXT NOT NULL REFERENCES guilds(id) ON DELETE CASCADE ON UPDATE CASCADE,
webhook_id TEXT NOT NULL REFERENCES webhooks(id) ON DELETE CASCADE ON UPDATE CASCADE,
repo_name TEXT NOT NULL,
channel_id TEXT NOT NULL, -- Channel ID to post to
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_by TEXT NOT NULL,
last_updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
last_updated_by TEXT NOT NULL
);
CREATE TABLE event_modifiers (
id TEXT PRIMARY KEY NOT NULL,
guild_id TEXT NOT NULL REFERENCES guilds(id) ON DELETE CASCADE ON UPDATE CASCADE,
webhook_id TEXT NOT NULL REFERENCES webhooks(id) ON DELETE CASCADE ON UPDATE CASCADE, -- Webhook to apply to
repo_id TEXT REFERENCES repos(id) ON DELETE CASCADE ON UPDATE CASCADE, -- Optional, if not set, will assume all repos
events TEXT[] NOT NULL DEFAULT '{}', -- Events to capture in this modifier
blacklisted boolean not null default false, -- Whether or not these events are blacklisted or not
whitelisted boolean not null default false, -- Whether or not only these events can be sent
redirect_channel TEXT, -- Channel ID to redirect to, otherwise use default channel
priority INTEGER NOT NULL, -- Priority to apply the modifiers in, applied in descending order
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
created_by TEXT NOT NULL,
last_updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
last_updated_by TEXT NOT NULL
);
create table webhook_logs (
log_id text primary key not null,
guild_id TEXT NOT NULL REFERENCES guilds(id) ON DELETE CASCADE ON UPDATE CASCADE,
webhook_id text not null references webhooks (id) ON UPDATE CASCADE ON DELETE CASCADE,
entries text[] not null default '{}'
);