This repository has been archived by the owner on Dec 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.sql
681 lines (447 loc) · 14.4 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
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
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.3
-- Dumped by pg_dump version 9.6.3
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
--
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
SET search_path = public, pg_catalog;
--
-- Name: last_seen; Type: TYPE; Schema: public; Owner: jacr
--
CREATE TYPE last_seen AS ENUM (
'join',
'quit',
'message',
'update'
);
ALTER TYPE last_seen OWNER TO jacr;
--
-- Name: skip_reason; Type: TYPE; Schema: public; Owner: jacr
--
CREATE TYPE skip_reason AS ENUM (
'forbidden',
'nsfw',
'op',
'theme',
'unavailable'
);
ALTER TYPE skip_reason OWNER TO jacr;
--
-- Name: song_type; Type: TYPE; Schema: public; Owner: jacr
--
CREATE TYPE song_type AS ENUM (
'youtube',
'soundcloud'
);
ALTER TYPE song_type OWNER TO jacr;
SET default_tablespace = '';
SET default_with_oids = false;
--
-- Name: dubtrack_users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE dubtrack_users (
id integer NOT NULL,
karma integer DEFAULT 0 NOT NULL,
dub_id character(24) NOT NULL,
username text NOT NULL,
seen_time timestamp without time zone DEFAULT now() NOT NULL,
seen_message text DEFAULT ''::text NOT NULL,
seen_type last_seen,
rethink_id character varying(36)
);
ALTER TABLE dubtrack_users OWNER TO postgres;
--
-- Name: dubtrack_users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE dubtrack_users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE dubtrack_users_id_seq OWNER TO postgres;
--
-- Name: dubtrack_users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE dubtrack_users_id_seq OWNED BY dubtrack_users.id;
--
-- Name: goose_db_version; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE goose_db_version (
id integer NOT NULL,
version_id bigint NOT NULL,
is_applied boolean NOT NULL,
tstamp timestamp without time zone DEFAULT now()
);
ALTER TABLE goose_db_version OWNER TO postgres;
--
-- Name: goose_db_version_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE goose_db_version_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE goose_db_version_id_seq OWNER TO postgres;
--
-- Name: goose_db_version_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE goose_db_version_id_seq OWNED BY goose_db_version.id;
--
-- Name: history; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE history (
id integer NOT NULL,
dub_id character(24) NOT NULL,
score_down integer DEFAULT 0 NOT NULL,
score_grab integer DEFAULT 0 NOT NULL,
score_up integer DEFAULT 0 NOT NULL,
song integer NOT NULL,
"user" integer NOT NULL,
"time" timestamp without time zone DEFAULT now() NOT NULL
);
ALTER TABLE history OWNER TO postgres;
--
-- Name: history_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE history_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE history_id_seq OWNER TO postgres;
--
-- Name: history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE history_id_seq OWNED BY history.id;
--
-- Name: notices; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE notices (
id integer NOT NULL,
message text NOT NULL,
title text NOT NULL
);
ALTER TABLE notices OWNER TO postgres;
--
-- Name: notices_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE notices_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE notices_id_seq OWNER TO postgres;
--
-- Name: notices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE notices_id_seq OWNED BY notices.id;
--
-- Name: response_commands; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE response_commands (
id integer NOT NULL,
name character varying(32) NOT NULL,
"group" integer NOT NULL
);
ALTER TABLE response_commands OWNER TO postgres;
--
-- Name: response_commands_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE response_commands_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE response_commands_id_seq OWNER TO postgres;
--
-- Name: response_commands_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE response_commands_id_seq OWNED BY response_commands.id;
--
-- Name: response_groups; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE response_groups (
id integer NOT NULL,
messages text[] NOT NULL
);
ALTER TABLE response_groups OWNER TO postgres;
--
-- Name: response_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE response_groups_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE response_groups_id_seq OWNER TO postgres;
--
-- Name: response_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE response_groups_id_seq OWNED BY response_groups.id;
--
-- Name: settings; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE settings (
name text NOT NULL,
value jsonb NOT NULL
);
ALTER TABLE settings OWNER TO postgres;
--
-- Name: songs; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE songs (
id integer NOT NULL,
fkid character varying(32) NOT NULL,
name text NOT NULL,
last_play timestamp without time zone NOT NULL,
skip_reason skip_reason,
recent_plays integer DEFAULT 0 NOT NULL,
total_plays integer DEFAULT 0 NOT NULL,
rethink_id character varying(36),
type song_type NOT NULL,
retagged boolean DEFAULT false NOT NULL,
autoretagged boolean DEFAULT false
);
ALTER TABLE songs OWNER TO postgres;
--
-- Name: songs_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE songs_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE songs_id_seq OWNER TO postgres;
--
-- Name: songs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE songs_id_seq OWNED BY songs.id;
--
-- Name: users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE users (
id integer NOT NULL,
username character varying(255) NOT NULL,
password character(60) NOT NULL,
email character varying(254) NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL,
updated_at timestamp without time zone DEFAULT now() NOT NULL,
activated boolean DEFAULT false NOT NULL,
banned boolean DEFAULT false NOT NULL,
slug character varying(255) NOT NULL,
level integer DEFAULT 1 NOT NULL
);
ALTER TABLE users OWNER TO postgres;
--
-- Name: users_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres
--
CREATE SEQUENCE users_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER TABLE users_id_seq OWNER TO postgres;
--
-- Name: users_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres
--
ALTER SEQUENCE users_id_seq OWNED BY users.id;
--
-- Name: dubtrack_users id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY dubtrack_users ALTER COLUMN id SET DEFAULT nextval('dubtrack_users_id_seq'::regclass);
--
-- Name: goose_db_version id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY goose_db_version ALTER COLUMN id SET DEFAULT nextval('goose_db_version_id_seq'::regclass);
--
-- Name: history id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY history ALTER COLUMN id SET DEFAULT nextval('history_id_seq'::regclass);
--
-- Name: notices id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY notices ALTER COLUMN id SET DEFAULT nextval('notices_id_seq'::regclass);
--
-- Name: response_commands id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY response_commands ALTER COLUMN id SET DEFAULT nextval('response_commands_id_seq'::regclass);
--
-- Name: response_groups id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY response_groups ALTER COLUMN id SET DEFAULT nextval('response_groups_id_seq'::regclass);
--
-- Name: songs id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY songs ALTER COLUMN id SET DEFAULT nextval('songs_id_seq'::regclass);
--
-- Name: users id; Type: DEFAULT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY users ALTER COLUMN id SET DEFAULT nextval('users_id_seq'::regclass);
--
-- Name: dubtrack_users dubtrack_users_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY dubtrack_users
ADD CONSTRAINT dubtrack_users_pkey PRIMARY KEY (id);
--
-- Name: goose_db_version goose_db_version_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY goose_db_version
ADD CONSTRAINT goose_db_version_pkey PRIMARY KEY (id);
--
-- Name: history history_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY history
ADD CONSTRAINT history_pkey PRIMARY KEY (id);
--
-- Name: notices notices_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY notices
ADD CONSTRAINT notices_pkey PRIMARY KEY (id);
--
-- Name: response_commands response_commands_id_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY response_commands
ADD CONSTRAINT response_commands_id_pkey PRIMARY KEY (id);
--
-- Name: response_commands response_commands_name_group_pk; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY response_commands
ADD CONSTRAINT response_commands_name_group_pk UNIQUE (name, "group");
--
-- Name: response_commands response_commands_name_pk; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY response_commands
ADD CONSTRAINT response_commands_name_pk UNIQUE (name);
--
-- Name: response_groups response_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY response_groups
ADD CONSTRAINT response_groups_pkey PRIMARY KEY (id);
--
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY settings
ADD CONSTRAINT settings_pkey PRIMARY KEY (name);
--
-- Name: songs songs_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY songs
ADD CONSTRAINT songs_pkey PRIMARY KEY (id);
--
-- Name: songs songs_type_fkid_pk; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY songs
ADD CONSTRAINT songs_type_fkid_pk UNIQUE (type, fkid);
--
-- Name: users users_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY users
ADD CONSTRAINT users_email_key UNIQUE (email);
--
-- Name: users users_id_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY users
ADD CONSTRAINT users_id_pkey PRIMARY KEY (id);
--
-- Name: users users_slug_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY users
ADD CONSTRAINT users_slug_key UNIQUE (slug);
--
-- Name: users users_username_key; Type: CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY users
ADD CONSTRAINT users_username_key UNIQUE (username);
--
-- Name: dubtrack_users_dub_id_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX dubtrack_users_dub_id_uindex ON dubtrack_users USING btree (dub_id);
--
-- Name: dubtrack_users_id_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX dubtrack_users_id_uindex ON dubtrack_users USING btree (id);
--
-- Name: dubtrack_users_rethinkid_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX dubtrack_users_rethinkid_uindex ON dubtrack_users USING btree (rethink_id);
--
-- Name: dubtrack_users_username_index; Type: INDEX; Schema: public; Owner: postgres
--
CREATE INDEX dubtrack_users_username_index ON dubtrack_users USING btree (username);
--
-- Name: history_dub_id_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX history_dub_id_uindex ON history USING btree (dub_id);
--
-- Name: history_id_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX history_id_uindex ON history USING btree (id);
--
-- Name: notices_id_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX notices_id_uindex ON notices USING btree (id);
--
-- Name: notices_title_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX notices_title_uindex ON notices USING btree (title);
--
-- Name: songs_fkid_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX songs_fkid_uindex ON songs USING btree (fkid);
--
-- Name: songs_id_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX songs_id_uindex ON songs USING btree (id);
--
-- Name: songs_rethink_id_uindex; Type: INDEX; Schema: public; Owner: postgres
--
CREATE UNIQUE INDEX songs_rethink_id_uindex ON songs USING btree (rethink_id);
--
-- Name: history history_dubtrack_users_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY history
ADD CONSTRAINT history_dubtrack_users_id_fk FOREIGN KEY ("user") REFERENCES dubtrack_users(id);
--
-- Name: history history_songs_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY history
ADD CONSTRAINT history_songs_id_fk FOREIGN KEY (song) REFERENCES songs(id);
--
-- Name: response_commands response_commands_response_groups_id_fk; Type: FK CONSTRAINT; Schema: public; Owner: postgres
--
ALTER TABLE ONLY response_commands
ADD CONSTRAINT response_commands_response_groups_id_fk FOREIGN KEY ("group") REFERENCES response_groups(id);
--
-- PostgreSQL database dump complete
--