-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdatabase.sql
More file actions
509 lines (426 loc) · 11.1 KB
/
database.sql
File metadata and controls
509 lines (426 loc) · 11.1 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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
create table activity_log
(
uid bigint not null,
game varchar(128) not null,
time bigint default 0,
constraint idx_27130_primary
primary key (uid, game)
);
create table attachments
(
channel bigint not null,
attachment text not null,
constraint idx_27134_primary
primary key (channel)
);
create table automute_blacklist
(
channel bigint not null,
guild bigint not null,
constraint idx_27140_primary
primary key (channel)
);
create index idx_27140_server_id
on automute_blacklist (guild);
create table banned_users
(
uid bigint not null,
reason text not null,
constraint idx_27146_primary
primary key (uid)
);
create table bot_staff
(
uid bigint not null,
auth_level smallint not null,
constraint idx_27152_primary
primary key (uid)
);
create table changelog
(
id serial not null,
changes text,
time timestamp default CURRENT_TIMESTAMP not null,
constraint idx_27157_primary
primary key (id)
);
create table command_blacklist
(
id bigserial not null,
command text,
type smallint not null,
uid bigint,
role bigint,
channel bigint,
guild bigint,
constraint idx_27170_primary
primary key (id)
);
create index idx_27170_role
on command_blacklist (role);
create index idx_27170_channel
on command_blacklist (channel);
create index idx_27170_user
on command_blacklist (uid);
create index idx_27170_server
on command_blacklist (guild);
create table command_stats
(
parent varchar(40) not null,
cmd varchar(200) default '0'::character varying,
uses bigint default 0
);
create index idx_27177_uses
on command_stats (uses);
create unique index idx_27177_parent
on command_stats (parent, cmd);
create table command_usage
(
cmd TEXT NOT NULL,
used_at TIMESTAMP WITHOUT TIME ZONE NOT NULL,
uid BIGINT DEFAULT NULL,
guild BIGINT DEFAULT NULL
);
create index cmd_name_index
on command_usage (cmd);
create table emotes
(
name text not null,
emote varchar(20) not null,
guild bigint,
constraint idx_27182_primary
primary key (emote)
);
create index idx_27182_server_id
on emotes (guild);
create table giveaways
(
guild bigint not null,
title text not null,
message bigint not null,
channel bigint not null,
winners smallint not null,
expires_in timestamp,
constraint idx_27188_primary
primary key (message)
);
create index idx_27188_server_id
on giveaways (guild);
create table guilds
(
guild bigint not null,
mute_role bigint,
modlog bigint,
on_delete_channel bigint,
on_edit_channel bigint,
keeproles boolean default false,
on_join_channel bigint,
on_leave_channel bigint,
on_join_message text,
on_leave_message text,
color_on_join boolean default false,
on_edit_message text,
on_delete_message text,
automute boolean default false,
automute_limit smallint default 10,
automute_time interval,
on_delete_embed boolean default false,
on_edit_embed boolean default false,
dailygachi bigint,
last_banner TEXT DEFAULT NULL,
constraint idx_27194_primary
primary key (guild)
);
create table guild_blacklist
(
guild bigint not null,
reason text not null,
constraint idx_27206_primary
primary key (guild)
);
create table join_leave
(
uid bigint not null,
at timestamp default CURRENT_TIMESTAMP not null,
guild bigint not null,
value smallint not null,
constraint idx_27212_primary
primary key (uid, guild)
);
create table last_seen_users
(
uid bigint not null,
username varchar(40) not null,
guild bigint default 0 not null,
last_seen timestamp default CURRENT_TIMESTAMP not null,
constraint idx_27216_primary
primary key (uid, guild)
);
create index idx_27216_username
on last_seen_users (username);
create table mention_stats
(
guild bigint not null,
role bigint not null,
role_name varchar(100) not null,
amount bigint default 1,
constraint idx_27221_primary
primary key (guild, role)
);
create table messages
(
guild bigint,
channel bigint,
user_id bigint,
message_id bigint default 0 not null,
constraint idx_27225_primary
primary key (message_id)
);
create index idx_27225_user_id
on messages (user_id);
create index idx_27225_channel_id
on messages (channel);
create index idx_27225_server_id
on messages (guild);
create index idx_27225_time
on messages (time);
create table mute_roll_stats
(
guild bigint not null,
uid bigint not null,
wins integer default 0,
games integer default 1,
current_streak smallint default 0,
biggest_streak smallint default 0,
constraint idx_27230_primary
primary key (guild, uid)
);
create index idx_27230_wins
on mute_roll_stats (wins);
create index idx_27230_games
on mute_roll_stats (games);
create table nn_text
(
message text not null
);
create table pokespawns
(
guild bigint not null,
name varchar(20) not null,
count integer default 1,
constraint idx_27243_primary
primary key (guild, name)
);
create table polls
(
guild bigint not null,
title text not null,
strict boolean default false,
message bigint not null,
channel bigint not null,
expires_in timestamp,
ignore_on_dupe boolean default false,
multiple_votes boolean default false,
max_winners integer default 1,
giveaway boolean default false,
constraint idx_27250_primary
primary key (message)
);
create table pollemotes
(
poll_id bigint not null,
emote_id varchar(20) not null,
constraint idx_27247_primary
primary key (poll_id, emote_id),
constraint pollemotes_ibfk_1
foreign key (poll_id) references polls
on update cascade on delete cascade
);
create index idx_27247_emote_id
on pollemotes (emote_id);
create index idx_27250_server_id
on polls (guild);
create table prefixes
(
prefix varchar(30) default '!'::character varying not null,
guild bigint not null,
constraint idx_27261_primary
primary key (prefix, guild)
);
create table roles
(
id bigint not null,
guild bigint not null,
constraint idx_27265_primary
primary key (id)
);
create table join_dates
(
uid bigint not null,
guild bigint not null,
first_join timestamp,
constraint join_date_index
primary key (uid, guild)
);
create table role_cooldown
(
uid bigint not null,
last_use timestamp,
constraint last_use_index
primary key (uid)
);
create table automute_whitelist
(
role bigint not null,
guild bigint not null,
constraint idx_27143_primary
primary key (role),
constraint automute_whitelist_ibfk_1
foreign key (role) references roles
on update restrict on delete cascade
);
create index idx_27143_server
on automute_whitelist (guild);
create table colors
(
id bigint not null,
name varchar(127) not null,
value integer not null,
lab_l double precision not null,
lab_a double precision not null,
lab_b double precision not null,
constraint idx_27165_primary
primary key (id),
constraint colors_ibfk_1
foreign key (id) references roles
on update restrict on delete cascade
);
create index idx_27165_value
on colors (value);
create index idx_27265_server
on roles (guild);
create table role_granting
(
user_role bigint not null,
role bigint not null,
guild bigint not null,
uid bigint not null,
constraint idx_27268_primary
primary key (user_role, role, uid),
constraint role_granting_ibfk_2
foreign key (role) references roles
on update restrict on delete cascade
);
create index idx_27268_server_id
on role_granting (guild);
create index idx_27268_role_id
on role_granting (role);
create table temproles
(
role bigint not null,
uid bigint not null,
guild bigint not null,
expires_at timestamp default CURRENT_TIMESTAMP not null,
constraint idx_27271_primary
primary key (role, uid)
);
create table timeouts
(
guild bigint not null,
uid bigint not null,
expires_on timestamp not null,
constraint idx_27274_primary
primary key (uid, guild)
);
create table timeout_logs
(
guild bigint not null,
uid bigint not null,
author bigint not null,
embed text,
reason text not null,
message bigint,
id bigserial not null,
time timestamp default CURRENT_TIMESTAMP not null,
duration integer,
show_in_logs boolean default true,
constraint idx_27279_primary
primary key (id)
);
create index idx_27279_author
on timeout_logs (author);
create index idx_27279_guild
on timeout_logs (guild);
create index idx_27279_show_in_logs
on timeout_logs (show_in_logs);
create index idx_27279_user
on timeout_logs (uid);
create table timeout_logs_old
(
guild bigint not null,
"user" bigint not null,
time bigint not null,
reason text not null
);
create index idx_27288_user
on timeout_logs_old ("user");
create index idx_27288_guild
on timeout_logs_old (guild);
create table todo
(
time timestamp default CURRENT_TIMESTAMP not null,
completed_at timestamp,
completed boolean default false,
todo text,
priority smallint default 0 not null,
id serial not null,
constraint idx_27296_primary
primary key (id)
);
create table userroles
(
uid bigint not null,
role bigint not null,
constraint idx_27306_primary
primary key (uid, role),
constraint userroles_ibfk_1
foreign key (role) references roles
on update restrict on delete cascade
);
create index idx_27306_role_id
on userroles (role);
create table users
(
id bigint not null,
timezone text DEFAULT NULL,
constraint idx_27309_primary
primary key (id)
);
CREATE EXTENSION IF NOT EXISTS citext;
CREATE TABLE r9k
(
message CITEXT PRIMARY KEY
);
CREATE TABLE infections (
uid BIGINT PRIMARY KEY,
status BOOL DEFAULT NULL,
infected_at timestamp DEFAULT current_timestamp NOT NULL
);
CREATE TABLE candidates (
uid BIGINT PRIMARY KEY,
is_participating BOOLEAN DEFAULT FALSE,
description TEXT DEFAULT NULL
);
CREATE TABLE elections (
voter_id BIGINT PRIMARY KEY,
candidate_id BIGINT NOT NULL REFERENCES candidates,
vote_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
);
CREATE TABLE event_users (
uid BIGINT PRIMARY KEY,
points INT NOT NULL DEFAULT 0,
protected_until TIMESTAMP DEFAULT NULL
);
CREATE TABLE do_not_track (
uid BIGINT PRIMARY KEY
);