-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpg.sql
66 lines (53 loc) · 2.12 KB
/
pg.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
create schema if not exists anon_muting;
create table if not exists anon_muting.users
(
user_id text not null
constraint users_pk
primary key,
muted boolean default false not null,
offence smallint default 0 not null,
muted_at timestamp
);
alter table anon_muting.users
owner to current_user;
create unique index if not exists users_user_id_uindex
on anon_muting.users (user_id);
create table if not exists anon_muting.events
(
created_by text not null,
submissions_channel_id text not null,
review_channel_id text not null,
event_id serial not null
constraint events_pk
primary key,
name text not null,
active boolean default true not null,
restriction integer default 0 not null
);
alter table anon_muting.events
owner to current_user;
create unique index if not exists events_submissions_channel_id_uindex
on anon_muting.events (submissions_channel_id);
create unique index if not exists events_event_id_uindex
on anon_muting.events (event_id);
create table if not exists anon_muting.submissions
(
submission_id bigserial not null
constraint submissions_pk
primary key,
user_id text not null,
approved boolean,
review_message_id text not null,
event_id integer not null
constraint submissions_events_event_id_fk
references anon_muting.events,
reviewed_by text
);
alter table anon_muting.submissions
owner to current_user;
create unique index if not exists submissions_review_message_id_uindex
on anon_muting.submissions (review_message_id);
create unique index if not exists submissions_review_message_id_uindex_2
on anon_muting.submissions (review_message_id);
create unique index if not exists submissions_submission_id_uindex
on anon_muting.submissions (submission_id);