-
Notifications
You must be signed in to change notification settings - Fork 3
/
schema.sql
57 lines (41 loc) · 1.46 KB
/
schema.sql
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
CREATE TABLE IF NOT EXISTS suggestions (
-- suggestion id
idx SERIAL PRIMARY KEY,
-- user that submitted the emoji
user_id BIGINT,
-- message id in the #council-queue
council_message_id BIGINT,
-- message id in the #approval-queue
public_message_id BIGINT,
-- message id in the #suggestions
suggestions_message_id BIGINT,
-- emoji data
emoji_id BIGINT,
emoji_name TEXT,
emoji_animated BOOLEAN,
note TEXT,
-- votes
upvotes INT DEFAULT 0,
downvotes INT DEFAULT 0,
-- timestamps
submission_time TIMESTAMP, -- when this was submitted
validation_time TIMESTAMP, -- when this was approved or denied
-- validation
council_approved BOOLEAN, -- was the emoji approved by Council?
forced_reason TEXT, -- reason for Council validation being forced.
forced_by BIGINT, -- ID of the user who forced this. if not forced, this is NULL.
revoked BOOLEAN -- emoji was revoked by submitter
);
CREATE TABLE IF NOT EXISTS council_votes (
-- idx of the suggestion this vote is for
suggestion_index INT REFERENCES suggestions ON DELETE CASCADE,
-- user that made this vote
user_id BIGINT,
PRIMARY KEY (suggestion_index, user_id),
-- has this user voted approve?
has_approved BOOLEAN DEFAULT FALSE,
-- has this user voted deny?
has_denied BOOLEAN DEFAULT FALSE,
-- time when this vote was made
vote_time TIMESTAMP DEFAULT (now() AT TIME ZONE 'utc')
);