-
Notifications
You must be signed in to change notification settings - Fork 907
/
schema.go
83 lines (67 loc) · 2.42 KB
/
schema.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package customcommands
var DBSchemas = []string{`
CREATE TABLE IF NOT EXISTS custom_command_groups (
id BIGSERIAL PRIMARY KEY,
guild_id BIGINT NOT NULL,
name TEXT NOT NULL,
ignore_roles BIGINT[],
ignore_channels BIGINT[],
whitelist_roles BIGINT[],
whitelist_channels BIGINT[]
);
`, `
CREATE TABLE IF NOT EXISTS custom_commands (
local_id BIGINT NOT NULL,
guild_id BIGINT NOT NULL,
group_id BIGINT references custom_command_groups(id) ON DELETE SET NULL,
trigger_type INT NOT NULL,
text_trigger TEXT NOT NULL,
text_trigger_case_sensitive BOOL NOT NULL,
time_trigger_interval INT NOT NULL,
time_trigger_excluding_days SMALLINT[] NOT NULL,
time_trigger_excluding_hours SMALLINT[] NOT NULL,
last_run TIMESTAMP WITH TIME ZONE,
next_run TIMESTAMP WITH TIME ZONE,
responses TEXT[] NOT NULL,
channels BIGINT[],
channels_whitelist_mode BOOL NOT NULL,
roles BIGINT[],
roles_whitelist_mode BOOL NOT NULL,
PRIMARY KEY(guild_id, local_id)
);
`, `
CREATE INDEX IF NOT EXISTS custom_commands_guild_idx ON custom_commands(guild_id);
`, `
CREATE INDEX IF NOT EXISTS custom_commands_next_run_idx ON custom_commands(next_run);
`, `
ALTER TABLE custom_commands ADD COLUMN IF NOT EXISTS context_channel BIGINT NOT NULL DEFAULT 0;
`, `
ALTER TABLE custom_commands ADD COLUMN IF NOT EXISTS reaction_trigger_mode SMALLINT NOT NULL DEFAULT 0;
`, `
ALTER TABLE custom_commands ADD COLUMN IF NOT EXISTS last_error TEXT NOT NULL DEFAULT '';
`, `
ALTER TABLE custom_commands ADD COLUMN IF NOT EXISTS last_error_time TIMESTAMP WITH TIME ZONE;
`, `
ALTER TABLE custom_commands ADD COLUMN IF NOT EXISTS run_count INT NOT NULL DEFAULT 0;
`, `
ALTER TABLE custom_commands ADD COLUMN IF NOT EXISTS show_errors BOOLEAN NOT NULL DEFAULT true;
`, `
ALTER TABLE custom_commands ADD COLUMN IF NOT EXISTS disabled BOOLEAN NOT NULL DEFAULT false;
`, `
CREATE TABLE IF NOT EXISTS templates_user_database (
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
expires_at TIMESTAMP WITH TIME ZONE,
guild_id BIGINT NOT NULL,
user_id BIGINT NOT NULL,
key TEXT NOT NULL,
value_num DOUBLE PRECISION NOT NULL,
value_raw BYTEA NOT NULL,
UNIQUE(guild_id, user_id, key)
);
`, `
CREATE INDEX IF NOT EXISTS templates_user_database_combined_idx ON templates_user_database (guild_id, user_id, key, value_num);
`, `
CREATE INDEX IF NOT EXISTS templates_user_database_expires_idx ON templates_user_database (expires_at);
`}