-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinit.sql
4720 lines (3096 loc) · 124 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
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
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- Create the roles
CREATE ROLE backup;
CREATE ROLE clickhouse;
CREATE ROLE peerdb;
CREATE ROLE tickets;
CREATE ROLE votelistener;
--
-- PostgreSQL database dump
--
-- Dumped from database version 16.6 (Ubuntu 16.6-1.pgdg20.04+1)
-- Dumped by pg_dump version 16.6 (Ubuntu 16.6-1.pgdg20.04+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;
--
-- Name: public; Type: SCHEMA; Schema: -; Owner: postgres
--
-- *not* creating schema, since initdb creates it
ALTER SCHEMA public OWNER TO postgres;
--
-- Name: pg_stat_statements; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_stat_statements WITH SCHEMA public;
--
-- Name: EXTENSION pg_stat_statements; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION pg_stat_statements IS 'track execution statistics of all SQL statements executed';
--
-- 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';
--
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
--
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
--
-- Name: premium_source; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.premium_source AS ENUM (
'discord',
'patreon',
'voting',
'key'
);
ALTER TYPE public.premium_source OWNER TO postgres;
--
-- Name: premium_tier; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.premium_tier AS ENUM (
'premium',
'whitelabel'
);
ALTER TYPE public.premium_tier OWNER TO postgres;
--
-- Name: sku_type; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.sku_type AS ENUM (
'subscription',
'consumable',
'durable'
);
ALTER TYPE public.sku_type OWNER TO postgres;
--
-- Name: ticket_status; Type: TYPE; Schema: public; Owner: postgres
--
CREATE TYPE public.ticket_status AS ENUM (
'OPEN',
'PENDING',
'CLOSED'
);
ALTER TYPE public.ticket_status OWNER TO postgres;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: active_language; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.active_language (
guild_id bigint NOT NULL,
language character varying(8) NOT NULL
);
ALTER TABLE public.active_language OWNER TO tickets;
--
-- Name: archive_channel; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.archive_channel (
guild_id bigint NOT NULL,
channel_id bigint
);
ALTER TABLE public.archive_channel OWNER TO tickets;
--
-- Name: archive_messages; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.archive_messages (
guild_id bigint NOT NULL,
ticket_id integer NOT NULL,
channel_id bigint NOT NULL,
message_id bigint NOT NULL
);
ALTER TABLE public.archive_messages OWNER TO postgres;
--
-- Name: auto_close; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.auto_close (
guild_id bigint NOT NULL,
enabled boolean NOT NULL,
since_open_with_no_response interval,
since_last_message interval,
on_user_leave boolean
);
ALTER TABLE public.auto_close OWNER TO tickets;
--
-- Name: auto_close_exclude; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.auto_close_exclude (
guild_id bigint NOT NULL,
ticket_id integer NOT NULL
);
ALTER TABLE public.auto_close_exclude OWNER TO tickets;
--
-- Name: blacklist; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.blacklist (
guild_id bigint NOT NULL,
user_id bigint NOT NULL
);
ALTER TABLE public.blacklist OWNER TO tickets;
--
-- Name: bot_staff; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.bot_staff (
user_id bigint NOT NULL
);
ALTER TABLE public.bot_staff OWNER TO tickets;
--
-- Name: category_update_queue; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.category_update_queue (
guild_id bigint NOT NULL,
ticket_id bigint NOT NULL,
new_status public.ticket_status NOT NULL,
status_changed_at timestamp with time zone NOT NULL
);
ALTER TABLE public.category_update_queue OWNER TO postgres;
--
-- Name: channel_category; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.channel_category (
guild_id bigint NOT NULL,
category_id bigint NOT NULL
);
ALTER TABLE public.channel_category OWNER TO tickets;
--
-- Name: claim_settings; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.claim_settings (
guild_id bigint NOT NULL,
support_can_view boolean NOT NULL,
support_can_type boolean NOT NULL
);
ALTER TABLE public.claim_settings OWNER TO tickets;
--
-- Name: close_confirmation; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.close_confirmation (
guild_id bigint NOT NULL,
confirm boolean NOT NULL
);
ALTER TABLE public.close_confirmation OWNER TO tickets;
--
-- Name: close_reason; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.close_reason (
guild_id bigint NOT NULL,
ticket_id integer NOT NULL,
close_reason text,
closed_by bigint
);
ALTER TABLE public.close_reason OWNER TO tickets;
--
-- Name: close_request; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.close_request (
guild_id bigint NOT NULL,
ticket_id integer NOT NULL,
user_id bigint NOT NULL,
message_id bigint,
close_at timestamp with time zone,
close_reason character varying(255)
);
ALTER TABLE public.close_request OWNER TO tickets;
--
-- Name: tickets; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.tickets (
id integer NOT NULL,
guild_id bigint NOT NULL,
channel_id bigint,
user_id bigint NOT NULL,
open boolean NOT NULL,
open_time timestamp with time zone NOT NULL,
welcome_message_id bigint,
panel_id integer,
has_transcript boolean DEFAULT false NOT NULL,
close_time timestamp with time zone,
join_message_id bigint,
is_thread boolean DEFAULT false,
notes_thread_id bigint,
status public.ticket_status DEFAULT 'OPEN'::public.ticket_status NOT NULL
);
ALTER TABLE public.tickets OWNER TO tickets;
--
-- Name: counter_view; Type: VIEW; Schema: public; Owner: tickets
--
CREATE VIEW public.counter_view AS
SELECT guild_id,
(max(id) + 1) AS next_id
FROM public.tickets
GROUP BY guild_id;
ALTER VIEW public.counter_view OWNER TO tickets;
--
-- Name: custom_colours; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.custom_colours (
guild_id bigint NOT NULL,
colour_id smallint NOT NULL,
colour_code integer NOT NULL
);
ALTER TABLE public.custom_colours OWNER TO tickets;
--
-- Name: custom_integration_guilds; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.custom_integration_guilds (
integration_id integer NOT NULL,
guild_id bigint NOT NULL
);
ALTER TABLE public.custom_integration_guilds OWNER TO tickets;
--
-- Name: custom_integration_guild_counts; Type: MATERIALIZED VIEW; Schema: public; Owner: tickets
--
CREATE MATERIALIZED VIEW public.custom_integration_guild_counts AS
SELECT integration_id,
count(*) AS count
FROM public.custom_integration_guilds
GROUP BY integration_id
WITH NO DATA;
ALTER MATERIALIZED VIEW public.custom_integration_guild_counts OWNER TO tickets;
--
-- Name: custom_integration_headers; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.custom_integration_headers (
id integer NOT NULL,
integration_id integer NOT NULL,
name character varying(32) NOT NULL,
value character varying(255) NOT NULL
);
ALTER TABLE public.custom_integration_headers OWNER TO tickets;
--
-- Name: custom_integration_headers_id_seq; Type: SEQUENCE; Schema: public; Owner: tickets
--
CREATE SEQUENCE public.custom_integration_headers_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.custom_integration_headers_id_seq OWNER TO tickets;
--
-- Name: custom_integration_headers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tickets
--
ALTER SEQUENCE public.custom_integration_headers_id_seq OWNED BY public.custom_integration_headers.id;
--
-- Name: custom_integration_placeholders; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.custom_integration_placeholders (
id integer NOT NULL,
integration_id integer NOT NULL,
name character varying(32) NOT NULL,
json_path character varying(255) NOT NULL
);
ALTER TABLE public.custom_integration_placeholders OWNER TO tickets;
--
-- Name: custom_integration_placeholders_id_seq; Type: SEQUENCE; Schema: public; Owner: tickets
--
CREATE SEQUENCE public.custom_integration_placeholders_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.custom_integration_placeholders_id_seq OWNER TO tickets;
--
-- Name: custom_integration_placeholders_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tickets
--
ALTER SEQUENCE public.custom_integration_placeholders_id_seq OWNED BY public.custom_integration_placeholders.id;
--
-- Name: custom_integration_secret_values; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.custom_integration_secret_values (
secret_id integer NOT NULL,
integration_id integer NOT NULL,
guild_id bigint NOT NULL,
value character varying(255) NOT NULL
);
ALTER TABLE public.custom_integration_secret_values OWNER TO tickets;
--
-- Name: custom_integration_secret_values_secret_id_seq; Type: SEQUENCE; Schema: public; Owner: tickets
--
CREATE SEQUENCE public.custom_integration_secret_values_secret_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.custom_integration_secret_values_secret_id_seq OWNER TO tickets;
--
-- Name: custom_integration_secret_values_secret_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tickets
--
ALTER SEQUENCE public.custom_integration_secret_values_secret_id_seq OWNED BY public.custom_integration_secret_values.secret_id;
--
-- Name: custom_integration_secrets; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.custom_integration_secrets (
id integer NOT NULL,
integration_id integer NOT NULL,
name character varying(32) NOT NULL,
description character varying(255)
);
ALTER TABLE public.custom_integration_secrets OWNER TO tickets;
--
-- Name: custom_integration_secrets_id_seq; Type: SEQUENCE; Schema: public; Owner: tickets
--
CREATE SEQUENCE public.custom_integration_secrets_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.custom_integration_secrets_id_seq OWNER TO tickets;
--
-- Name: custom_integration_secrets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tickets
--
ALTER SEQUENCE public.custom_integration_secrets_id_seq OWNED BY public.custom_integration_secrets.id;
--
-- Name: custom_integrations; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.custom_integrations (
id integer NOT NULL,
owner_id bigint NOT NULL,
webhook_url character varying(255) NOT NULL,
http_method character varying(4) NOT NULL,
name character varying(32) NOT NULL,
description character varying(255) NOT NULL,
image_url character varying(255),
privacy_policy_url character varying(255),
public boolean DEFAULT false NOT NULL,
approved boolean DEFAULT false NOT NULL,
validation_url character varying(255) DEFAULT NULL::character varying
);
ALTER TABLE public.custom_integrations OWNER TO tickets;
--
-- Name: custom_integrations_id_seq; Type: SEQUENCE; Schema: public; Owner: tickets
--
CREATE SEQUENCE public.custom_integrations_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.custom_integrations_id_seq OWNER TO tickets;
--
-- Name: custom_integrations_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tickets
--
ALTER SEQUENCE public.custom_integrations_id_seq OWNED BY public.custom_integrations.id;
--
-- Name: dashboard_users; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.dashboard_users (
user_id bigint NOT NULL,
last_seen timestamp with time zone NOT NULL
);
ALTER TABLE public.dashboard_users OWNER TO postgres;
--
-- Name: discord_entitlements; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.discord_entitlements (
discord_id bigint NOT NULL,
entitlement_id uuid NOT NULL
);
ALTER TABLE public.discord_entitlements OWNER TO postgres;
--
-- Name: discord_store_skus; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.discord_store_skus (
discord_id bigint NOT NULL,
sku_id uuid NOT NULL
);
ALTER TABLE public.discord_store_skus OWNER TO postgres;
--
-- Name: dm_on_open; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.dm_on_open (
guild_id bigint NOT NULL,
dm_on_open boolean NOT NULL
);
ALTER TABLE public.dm_on_open OWNER TO tickets;
--
-- Name: embed_fields; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.embed_fields (
id integer NOT NULL,
embed_id integer NOT NULL,
name character varying(255) NOT NULL,
value text NOT NULL,
inline boolean NOT NULL,
CONSTRAINT value_length CHECK ((length(value) <= 1024))
);
ALTER TABLE public.embed_fields OWNER TO tickets;
--
-- Name: embed_fields_id_seq; Type: SEQUENCE; Schema: public; Owner: tickets
--
CREATE SEQUENCE public.embed_fields_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.embed_fields_id_seq OWNER TO tickets;
--
-- Name: embed_fields_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tickets
--
ALTER SEQUENCE public.embed_fields_id_seq OWNED BY public.embed_fields.id;
--
-- Name: embeds; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.embeds (
id integer NOT NULL,
guild_id bigint NOT NULL,
title character varying(255),
description text,
url character varying(255),
colour integer DEFAULT 3066993 NOT NULL,
author_name character varying(255),
author_icon_url character varying(255),
author_url character varying(255),
image_url character varying(255),
thumbnail_url character varying(255),
footer_text text,
footer_icon_url character varying(255),
"timestamp" timestamp without time zone,
CONSTRAINT colour_range CHECK (((colour >= 0) AND (colour <= 16777215))),
CONSTRAINT description_length CHECK ((length(description) <= 4096)),
CONSTRAINT footer_text_length CHECK ((length(footer_text) <= 2048))
);
ALTER TABLE public.embeds OWNER TO tickets;
--
-- Name: embeds_id_seq; Type: SEQUENCE; Schema: public; Owner: tickets
--
CREATE SEQUENCE public.embeds_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.embeds_id_seq OWNER TO tickets;
--
-- Name: embeds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tickets
--
ALTER SEQUENCE public.embeds_id_seq OWNED BY public.embeds.id;
--
-- Name: entitlements; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.entitlements (
id uuid DEFAULT gen_random_uuid() NOT NULL,
guild_id bigint,
user_id bigint,
sku_id uuid NOT NULL,
source public.premium_source NOT NULL,
expires_at timestamp with time zone
);
ALTER TABLE public.entitlements OWNER TO postgres;
--
-- Name: exit_survey_responses; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.exit_survey_responses (
guild_id bigint NOT NULL,
ticket_id integer NOT NULL,
form_id integer,
question_id integer NOT NULL,
response text
);
ALTER TABLE public.exit_survey_responses OWNER TO postgres;
--
-- Name: feedback_enabled; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.feedback_enabled (
guild_id bigint NOT NULL,
feedback_enabled boolean NOT NULL
);
ALTER TABLE public.feedback_enabled OWNER TO tickets;
--
-- Name: first_response_time; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.first_response_time (
guild_id bigint NOT NULL,
ticket_id integer NOT NULL,
user_id bigint NOT NULL,
response_time interval NOT NULL
);
ALTER TABLE public.first_response_time OWNER TO tickets;
--
-- Name: first_response_time_export; Type: VIEW; Schema: public; Owner: tickets
--
CREATE VIEW public.first_response_time_export AS
SELECT guild_id,
ticket_id,
user_id,
(date_part('epoch'::text, response_time))::integer AS response_time_seconds
FROM public.first_response_time;
ALTER VIEW public.first_response_time_export OWNER TO tickets;
--
-- Name: first_response_time_guild_view; Type: MATERIALIZED VIEW; Schema: public; Owner: tickets
--
CREATE MATERIALIZED VIEW public.first_response_time_guild_view AS
SELECT first_response_time.guild_id,
avg(first_response_time.response_time) AS all_time,
avg(first_response_time.response_time) FILTER (WHERE (tickets.open_time > (now() - '30 days'::interval))) AS monthly,
avg(first_response_time.response_time) FILTER (WHERE (tickets.open_time > (now() - '7 days'::interval))) AS weekly
FROM (public.first_response_time
JOIN public.tickets ON (((first_response_time.guild_id = tickets.guild_id) AND (first_response_time.ticket_id = tickets.id))))
GROUP BY first_response_time.guild_id
WITH NO DATA;
ALTER MATERIALIZED VIEW public.first_response_time_guild_view OWNER TO tickets;
--
-- Name: first_response_time_user_view; Type: MATERIALIZED VIEW; Schema: public; Owner: tickets
--
CREATE MATERIALIZED VIEW public.first_response_time_user_view AS
SELECT first_response_time.guild_id,
first_response_time.user_id,
avg(first_response_time.response_time) AS all_time,
avg(first_response_time.response_time) FILTER (WHERE (tickets.open_time > (now() - '30 days'::interval))) AS monthly,
avg(first_response_time.response_time) FILTER (WHERE (tickets.open_time > (now() - '7 days'::interval))) AS weekly
FROM (public.first_response_time
JOIN public.tickets ON (((first_response_time.guild_id = tickets.guild_id) AND (first_response_time.ticket_id = tickets.id))))
GROUP BY first_response_time.guild_id, first_response_time.user_id
WITH NO DATA;
ALTER MATERIALIZED VIEW public.first_response_time_user_view OWNER TO tickets;
--
-- Name: form_input; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.form_input (
id integer NOT NULL,
form_id integer NOT NULL,
custom_id character varying(100) NOT NULL,
style smallint NOT NULL,
label character varying(255) NOT NULL,
placeholder character varying(100),
required boolean DEFAULT true NOT NULL,
"position" integer NOT NULL,
min_length smallint,
max_length smallint,
CONSTRAINT check_position_max CHECK (("position" <= 5)),
CONSTRAINT check_position_positive CHECK (("position" >= 1))
);
ALTER TABLE public.form_input OWNER TO tickets;
--
-- Name: form_input_id_seq; Type: SEQUENCE; Schema: public; Owner: tickets
--
CREATE SEQUENCE public.form_input_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.form_input_id_seq OWNER TO tickets;
--
-- Name: form_input_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tickets
--
ALTER SEQUENCE public.form_input_id_seq OWNED BY public.form_input.id;
--
-- Name: forms; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.forms (
form_id integer NOT NULL,
guild_id bigint NOT NULL,
title character varying(255) NOT NULL,
custom_id character varying(100) NOT NULL
);
ALTER TABLE public.forms OWNER TO tickets;
--
-- Name: forms_form_id_seq; Type: SEQUENCE; Schema: public; Owner: tickets
--
CREATE SEQUENCE public.forms_form_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE public.forms_form_id_seq OWNER TO tickets;
--
-- Name: forms_form_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: tickets
--
ALTER SEQUENCE public.forms_form_id_seq OWNED BY public.forms.form_id;
--
-- Name: global_blacklist; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.global_blacklist (
user_id bigint NOT NULL,
reason character varying(255)
);
ALTER TABLE public.global_blacklist OWNER TO tickets;
--
-- Name: guild_leave_time; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.guild_leave_time (
guild_id bigint NOT NULL,
leave_time timestamp with time zone NOT NULL
);
ALTER TABLE public.guild_leave_time OWNER TO tickets;
--
-- Name: guild_metadata; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.guild_metadata (
guild_id bigint NOT NULL,
on_call_role bigint
);
ALTER TABLE public.guild_metadata OWNER TO tickets;
--
-- Name: legacy_premium_entitlement_guilds; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.legacy_premium_entitlement_guilds (
user_id bigint NOT NULL,
guild_id bigint NOT NULL,
entitlement_id uuid NOT NULL
);
ALTER TABLE public.legacy_premium_entitlement_guilds OWNER TO postgres;
--
-- Name: legacy_premium_entitlements; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE public.legacy_premium_entitlements (
user_id bigint NOT NULL,
tier integer NOT NULL,
sku_label character varying(255) NOT NULL,
expires_at timestamp without time zone NOT NULL,
is_legacy boolean NOT NULL,
sku_id uuid NOT NULL
);
ALTER TABLE public.legacy_premium_entitlements OWNER TO postgres;
--
-- Name: modmail_archive; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.modmail_archive (
uuid uuid NOT NULL,
guild_id bigint NOT NULL,
user_id bigint NOT NULL,
close_time timestamp without time zone NOT NULL
);
ALTER TABLE public.modmail_archive OWNER TO tickets;
--
-- Name: modmail_enabled; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.modmail_enabled (
guild_id bigint NOT NULL,
enabled boolean NOT NULL
);
ALTER TABLE public.modmail_enabled OWNER TO tickets;
--
-- Name: modmail_forced_guilds; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.modmail_forced_guilds (
bot_id bigint NOT NULL,
guild_id bigint NOT NULL
);
ALTER TABLE public.modmail_forced_guilds OWNER TO tickets;
--
-- Name: modmail_sessions; Type: TABLE; Schema: public; Owner: tickets
--
CREATE TABLE public.modmail_sessions (
uuid uuid DEFAULT public.uuid_generate_v4() NOT NULL,
guild_id bigint NOT NULL,
bot_id bigint NOT NULL,
user_id bigint NOT NULL,
staff_channel bigint NOT NULL,
welcome_message_id bigint NOT NULL
);