-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsql_config.sql
More file actions
77 lines (67 loc) · 1.88 KB
/
sql_config.sql
File metadata and controls
77 lines (67 loc) · 1.88 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
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
CREATE TABLE IF NOT EXISTS trophies
(
id VARCHAR(32) PRIMARY KEY,
name VARCHAR(64) NOT NULL
);
CREATE TABLE IF NOT EXISTS users
(
id BIGINT PRIMARY KEY,
points INT DEFAULT 0 CHECK ( points >= 0 ),
total_events INT DEFAULT 0,
won_events INT DEFAULT 0
);
CREATE TABLE IF NOT EXISTS inventories
(
id BIGINT NOT NULL REFERENCES users ON DELETE CASCADE,
trophy_id VARCHAR(32) NOT NULL REFERENCES trophies ON DELETE CASCADE,
obtained_on TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE (id, trophy_id)
);
CREATE TABLE IF NOT EXISTS nitro_shop
(
name VARCHAR(64) NOT NULL,
price INT NOT NULL,
gift_link VARCHAR(128) NOT NULL
);
CREATE TABLE IF NOT EXISTS events
(
id UUID PRIMARY KEY,
name VARCHAR(16) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
registration_channel_id BIGINT NOT NULL,
registration_message_id BIGINT NOT NULL
);
CREATE TABLE IF NOT EXISTS groups
(
event_id UUID REFERENCES events ON DELETE CASCADE NOT NULL,
start_time TIMESTAMP NOT NULL,
role_id BIGINT NOT NULL,
closed BOOLEAN DEFAULT FALSE,
UNIQUE (event_id, role_id)
);
CREATE TABLE IF NOT EXISTS stats
(
time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
online INT NOT NULL,
idle INT NOT NULL,
dnd INT NOT NULL
);
CREATE TABLE IF NOT EXISTS polls
(
message_id BIGINT NOT NULL,
option_id SMALLINT NOT NULL,
member_id BIGINT NOT NULL,
UNIQUE (message_id, member_id)
);
CREATE TABLE IF NOT EXISTS polls_messages
(
message_id BIGINT UNIQUE
);
CREATE TABLE IF NOT EXISTS version_data
(
id SMALLINT UNIQUE DEFAULT 0,
version SMALLINT NOT NULL
);
INSERT INTO version_data (id, version)
VALUES (0, 1)
ON CONFLICT DO NOTHING;