-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.sql
121 lines (105 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
CREATE TABLE IF NOT EXISTS public.guild
(
guild_id bigint NOT NULL,
premium boolean NOT NULL DEFAULT False,
default_log_webhook text,
has_guild_logs boolean NOT NULL DEFAULT False,
guild_log_webhook text,
has_member_logs boolean NOT NULL DEFAULT False,
member_log_webhook text,
has_messsage_logs boolean NOT NULL DEFAULT False,
message_log_webhook text,
has_role_logs boolean NOT NULL DEFAULT False,
role_log_webhook text,
has_channel_logs boolean NOT NULL DEFAULT False,
channel_log_webhook text,
has_voice_logs boolean NOT NULL DEFAULT False,
voice_log_webhook text,
has_join_leave_logs boolean NOT NULL DEFAULT False,
join_leave_log_webhook text,
has_mod_logs boolean NOT NULL DEFAULT False,
mod_log_webhook text,
has_raidmode_logs boolean NOT NULL DEFAULT False,
raidmode_log_webhook text,
has_raidmode_status boolean NOT NULL DEFAULT False,
required_age smallint NOT NULL DEFAULT 7,
has_greet_member boolean NOT NULL DEFAULT False,
member_greetings text[],
member_greeting_channel bigint,
has_farewell_member boolean NOT NULL DEFAULT False,
member_farewells text[],
member_farewell_channel bigint,
has_greet_bot boolean NOT NULL DEFAULT False,
bot_greeting_channel bigint,
has_farewell_bot boolean NOT NULL DEFAULT False,
bot_farewell_channel bigint,
has_bot_role boolean NOT NULL DEFAULT False,
bot_role bigint,
has_thread_logs boolean NOT NULL DEFAULT False,
thread_log_webhook text,
PRIMARY KEY (guild_id)
);
COMMENT ON TABLE public.guild
IS 'The main table of Zupie, holds all Guild related Information.';
CREATE TABLE IF NOT EXISTS public.member
(
member_id bigint,
premium_slots smallint NOT NULL DEFAULT 0,
"DM_Reminders" boolean NOT NULL DEFAULT False,
PRIMARY KEY (member_id)
);
COMMENT ON TABLE public.member
IS 'Holds member related information';
CREATE TABLE IF NOT EXISTS public.members_guilds
(
member_id bigint,
guild_id bigint,
afk_status boolean NOT NULL DEFAULT False,
afk_message text,
joincount smallint NOT NULL DEFAULT 0,
premium boolean NOT NULL DEFAULT False,
PRIMARY KEY (member_id, guild_id)
);
COMMENT ON TABLE public.members_guilds
IS 'Links the members table to the guilds table.';
CREATE TABLE IF NOT EXISTS public.reminders
(
reminder_id bigserial NOT NULL,
guild_id bigint,
member_id bigint,
reminder_time timestamp with time zone,
reminder_text text,
reminder_status boolean,
PRIMARY KEY (reminder_id)
);
ALTER TABLE IF EXISTS public.guild
ADD CONSTRAINT premium FOREIGN KEY (is_premium)
REFERENCES public.members_guilds (premium) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE IF EXISTS public.members_guilds
ADD CONSTRAINT member_id FOREIGN KEY (member_id)
REFERENCES public.member (member_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE IF EXISTS public.members_guilds
ADD CONSTRAINT guild_id FOREIGN KEY (guild_id)
REFERENCES public.guild (guild_id) MATCH SIMPLE
ON UPDATE CASCADE
ON DELETE CASCADE
NOT VALID;
ALTER TABLE IF EXISTS public.reminders
ADD CONSTRAINT guild FOREIGN KEY (guild_id)
REFERENCES public.guild (guild_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
ALTER TABLE IF EXISTS public.reminders
ADD CONSTRAINT "user" FOREIGN KEY (member_id)
REFERENCES public.member (member_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
NOT VALID;
END;