-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
431 lines (292 loc) · 10 KB
/
init.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
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
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.4 (Debian 16.4-1.pgdg120+1)
-- Dumped by pg_dump version 16.4 (Debian 16.4-1.pgdg120+1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: admins; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.admins (
user_id character varying(255) NOT NULL
);
ALTER TABLE public.admins OWNER TO jushbjj;
--
-- Name: attachmenthistory; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.attachmenthistory (
hash character varying(255) NOT NULL,
attachment_link character varying(255),
user_id character varying(255),
"timestamp" double precision NOT NULL
);
ALTER TABLE public.attachmenthistory OWNER TO jushbjj;
--
-- Name: bannedservers; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.bannedservers (
server_id integer NOT NULL
);
ALTER TABLE public.bannedservers OWNER TO jushbjj;
--
-- Name: bannedusers; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.bannedusers (
user_id character varying(255) NOT NULL
);
ALTER TABLE public.bannedusers OWNER TO jushbjj;
--
-- Name: channellist; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.channellist (
channel_name character varying(255) NOT NULL
);
ALTER TABLE public.channellist OWNER TO jushbjj;
--
-- Name: channels; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.channels (
channel_id character varying(255) NOT NULL,
server_id character varying(255) NOT NULL,
channel_category character varying(255) NOT NULL,
react boolean DEFAULT false
);
ALTER TABLE public.channels OWNER TO jushbjj;
--
-- Name: dataset; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.dataset (
id character varying(255) NOT NULL,
predicted text,
actual text
);
ALTER TABLE public.dataset OWNER TO jushbjj;
--
-- Name: messagehistory; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.messagehistory (
hash character varying(255) NOT NULL,
message_link character varying(255)[],
user_id character varying(255),
"timestamp" double precision NOT NULL
);
ALTER TABLE public.messagehistory OWNER TO jushbjj;
--
-- Name: roles; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.roles (
name character varying(50) NOT NULL,
color character varying(7) NOT NULL
);
ALTER TABLE public.roles OWNER TO jushbjj;
--
-- Name: servers; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.servers (
server_id integer NOT NULL,
server_name character varying(255) NOT NULL
);
ALTER TABLE public.servers OWNER TO jushbjj;
--
-- Name: tempcommandmessagehistory; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.tempcommandmessagehistory (
message_id integer NOT NULL,
user_id character varying(255),
content text NOT NULL
);
ALTER TABLE public.tempcommandmessagehistory OWNER TO jushbjj;
--
-- Name: tempcommandmessagehistory_message_id_seq; Type: SEQUENCE; Schema: public; Owner: jushbjj
--
CREATE SEQUENCE public.tempcommandmessagehistory_message_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.tempcommandmessagehistory_message_id_seq OWNER TO jushbjj;
--
-- Name: tempcommandmessagehistory_message_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: jushbjj
--
ALTER SEQUENCE public.tempcommandmessagehistory_message_id_seq OWNED BY public.tempcommandmessagehistory.message_id;
--
-- Name: usernames; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.usernames (
user_id character varying(255) NOT NULL,
name character varying(255),
id integer NOT NULL
);
ALTER TABLE public.usernames OWNER TO jushbjj;
--
-- Name: usernames_id_seq; Type: SEQUENCE; Schema: public; Owner: jushbjj
--
CREATE SEQUENCE public.usernames_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.usernames_id_seq OWNER TO jushbjj;
--
-- Name: usernames_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: jushbjj
--
ALTER SEQUENCE public.usernames_id_seq OWNED BY public.usernames.id;
--
-- Name: users; Type: TABLE; Schema: public; Owner: jushbjj
--
CREATE TABLE public.users (
hash character varying(255) NOT NULL,
user_id character varying(255) DEFAULT '0'::character varying,
role character varying(50) DEFAULT 'user'::character varying,
profile_picture character varying(255),
difficulty double precision DEFAULT 0,
difficulty_penalty double precision DEFAULT 0,
can_send_message boolean DEFAULT true,
nonce integer DEFAULT 0
);
ALTER TABLE public.users OWNER TO jushbjj;
--
-- Name: tempcommandmessagehistory message_id; Type: DEFAULT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.tempcommandmessagehistory ALTER COLUMN message_id SET DEFAULT nextval('public.tempcommandmessagehistory_message_id_seq'::regclass);
--
-- Name: usernames id; Type: DEFAULT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.usernames ALTER COLUMN id SET DEFAULT nextval('public.usernames_id_seq'::regclass);
--
-- Name: admins admins_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.admins
ADD CONSTRAINT admins_pkey PRIMARY KEY (user_id);
--
-- Name: attachmenthistory attachmenthistory_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.attachmenthistory
ADD CONSTRAINT attachmenthistory_pkey PRIMARY KEY (hash);
--
-- Name: bannedservers bannedservers_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.bannedservers
ADD CONSTRAINT bannedservers_pkey PRIMARY KEY (server_id);
--
-- Name: bannedusers bannedusers_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.bannedusers
ADD CONSTRAINT bannedusers_pkey PRIMARY KEY (user_id);
--
-- Name: channellist channellist_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.channellist
ADD CONSTRAINT channellist_pkey PRIMARY KEY (channel_name);
--
-- Name: channels channels_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.channels
ADD CONSTRAINT channels_pkey PRIMARY KEY (channel_id);
--
-- Name: dataset dataset_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.dataset
ADD CONSTRAINT dataset_pkey PRIMARY KEY (id);
--
-- Name: messagehistory messagehistory_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.messagehistory
ADD CONSTRAINT messagehistory_pkey PRIMARY KEY (hash);
--
-- Name: roles roles_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.roles
ADD CONSTRAINT roles_pkey PRIMARY KEY (name);
--
-- Name: servers servers_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.servers
ADD CONSTRAINT servers_pkey PRIMARY KEY (server_id);
--
-- Name: tempcommandmessagehistory tempcommandmessagehistory_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.tempcommandmessagehistory
ADD CONSTRAINT tempcommandmessagehistory_pkey PRIMARY KEY (message_id);
--
-- Name: usernames unique_user_id_name; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.usernames
ADD CONSTRAINT unique_user_id_name UNIQUE (user_id, name);
--
-- Name: usernames usernames_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.usernames
ADD CONSTRAINT usernames_pkey PRIMARY KEY (id);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (hash);
--
-- Name: users users_user_id_key; Type: CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_user_id_key UNIQUE (user_id);
--
-- Name: admins admins_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.admins
ADD CONSTRAINT admins_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;
--
-- Name: attachmenthistory attachmenthistory_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.attachmenthistory
ADD CONSTRAINT attachmenthistory_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;
--
-- Name: messagehistory messagehistory_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.messagehistory
ADD CONSTRAINT messagehistory_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;
--
-- Name: tempcommandmessagehistory tempcommandmessagehistory_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.tempcommandmessagehistory
ADD CONSTRAINT tempcommandmessagehistory_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;
--
-- Name: usernames usernames_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: jushbjj
--
ALTER TABLE ONLY public.usernames
ADD CONSTRAINT usernames_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.users(user_id) ON DELETE CASCADE;
--
-- PostgreSQL database dump complete
--
-- Insert default roles
INSERT INTO Roles (name, color) VALUES
('admin', '#FF0000'),
('user', '#0000FF')
ON CONFLICT (name) DO NOTHING;
-- Insert default channel names
INSERT INTO ChannelList (channel_name) VALUES
('general'),
('wormhole'),
('happenings'),
('qotd'),
('memes'),
('computers'),
('finance'),
('music'),
('cats'),
('spam-can'),
('test')
ON CONFLICT (channel_name) DO NOTHING;