-
Notifications
You must be signed in to change notification settings - Fork 116
/
schema.sql
201 lines (159 loc) · 3.55 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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
drop table if exists approvedinvites, channels, filteredwords, flags, levenshteinwords, members, friendcodes,
reminders, roles, rules, softbans, staff, tags, restrictions, timedroles, warns,
whitelistedwords, citizens, voteviews, votes, changedroles;
create table approvedinvites
(
code TEXT PRIMARY KEY,
uses INTEGER NOT NULL,
alias TEXT NOT NULL
);
create table channels
(
id BIGINT PRIMARY KEY,
name TEXT NOT NULL,
filtered BOOLEAN NOT NULL DEFAULT TRUE,
lock_level INTEGER NOT NULL DEFAULT 0,
mod_channel BOOLEAN NOT NULL DEFAULT FALSE
);
create table filteredwords
(
word TEXT PRIMARY KEY,
kind TEXT NOT NULL
);
create table flags
(
name TEXT PRIMARY KEY,
value BOOLEAN NOT NULL
);
create table levenshteinwords
(
word TEXT NOT NULL PRIMARY KEY,
threshold INTEGER NOT NULL,
kind TEXT NOT NULL,
whitelisted BOOLEAN NOT NULL DEFAULT FALSE
);
create table members
(
id BIGINT PRIMARY KEY,
watched BOOLEAN NOT NULL DEFAULT FALSE
);
create table friendcodes
(
user_id BIGINT PRIMARY KEY REFERENCES members(id),
fc_3ds BIGINT UNIQUE,
fc_switch BIGINT UNIQUE
);
create table reminders
(
id BIGINT PRIMARY KEY,
reminder_date timestamptz NOT NULL ,
author_id BIGINT NOT NULL REFERENCES members(id),
content TEXT NOT NULL
);
create table roles
(
id BIGINT PRIMARY KEY,
name TEXT NOT NULL
);
create table rules
(
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
description TEXT NOT NULL
);
create table softbans
(
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES members(id),
issuer_id BIGINT NOT NULL REFERENCES members(id),
reason TEXT NOT NULL,
UNIQUE (user_id)
);
create table staff
(
user_id BIGINT PRIMARY KEY REFERENCES members(id),
position TEXT NOT NULL,
console TEXT
);
create table tags
(
id BIGINT PRIMARY KEY,
title TEXT NOT NULL,
content TEXT NOT NULL,
author_id BIGINT NOT NULL REFERENCES members(id),
UNIQUE (title)
);
create table tag_aliases
(
tag_id BIGINT REFERENCES tags(id) ON DELETE CASCADE,
alias TEXT UNIQUE,
primary key(tag_id, alias)
);
create table restrictions
(
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES members(id),
type TEXT NOT NULL,
end_date timestamptz,
alerted BOOLEAN NOT NULL DEFAULT FALSE,
UNIQUE (user_id, type)
);
create table timedroles
(
id BIGINT PRIMARY KEY,
role_id BIGINT NOT NULL,
user_id BIGINT NOT NULL REFERENCES members(id),
expiring_date timestamptz,
UNIQUE (role_id, user_id)
);
create table warns
(
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES members(id),
issuer_id BIGINT NOT NULL REFERENCES members(id),
reason TEXT,
type INT NOT NULL,
state INT NOT NULL,
deletion_time timestamptz,
deletion_reason TEXT,
deleter BIGINT REFERENCES members(id)
);
create table whitelistedwords
(
word TEXT PRIMARY KEY
);
create table citizens
(
id BIGINT PRIMARY KEY references members(id),
social_credit INTEGER NOT NULL DEFAULT 0
);
create table voteviews
(
id BIGINT PRIMARY KEY,
message_id BIGINT NOT NULL,
identifier TEXT NOT NULL,
author_id BIGINT NOT NULL,
options TEXT NOT NULL,
start timestamptz NOT NULL,
staff_only BOOLEAN NOT NULL
);
create table votes
(
view_id BIGINT NOT NULL REFERENCES voteviews(id) ON DELETE CASCADE,
voter_id BIGINT NOT NULL,
option TEXT NOT NULL,
PRIMARY KEY (view_id, voter_id)
);
create table changedroles
(
channel_id BIGINT NOT NULL REFERENCES channels(id) ON DELETE CASCADE,
role_id BIGINT NOT NULL,
original_value BOOLEAN,
PRIMARY KEY (channel_id, role_id)
);
create table channeloverwrites
(
id SERIAL PRIMARY KEY,
name TEXT UNIQUE,
overwrites JSON
);