-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathdbhub.sql
1218 lines (824 loc) · 30.7 KB
/
dbhub.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
-- noinspection SqlNoDataSourceInspectionForFile
--
-- PostgreSQL database dump
--
-- Dumped from database version 15.2
-- Dumped by pg_dump version 15.2
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: jsquery; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS jsquery WITH SCHEMA public;
--
-- Name: EXTENSION jsquery; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION jsquery IS 'data type for jsonb inspection';
--
-- Name: permissions; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.permissions AS ENUM (
'r',
'rw'
);
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: api_call_log; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.api_call_log (
api_call_id bigint NOT NULL,
api_call_date timestamp with time zone DEFAULT now(),
caller_id bigint,
db_owner_id bigint,
db_id bigint,
api_operation text NOT NULL,
api_caller_sw text
);
--
-- Name: COLUMN api_call_log.db_id; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.api_call_log.db_id IS 'This field must be nullable, as not all api calls act on a database';
--
-- Name: api_keys; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.api_keys (
key_id bigint NOT NULL,
user_id bigint,
key text NOT NULL,
date_created timestamp with time zone
);
--
-- Name: api_keys_key_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.api_keys_key_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: api_keys_key_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.api_keys_key_id_seq OWNED BY public.api_keys.key_id;
--
-- Name: api_log_log_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.api_log_log_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: api_log_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.api_log_log_id_seq OWNED BY public.api_call_log.api_call_id;
--
-- Name: database_downloads; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.database_downloads (
dl_id bigint NOT NULL,
db_id bigint NOT NULL,
user_id bigint,
ip_addr text NOT NULL,
server_sw text NOT NULL,
user_agent text NOT NULL,
download_date timestamp with time zone NOT NULL,
db_sha256 text NOT NULL
);
--
-- Name: database_downloads_dl_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.database_downloads_dl_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: database_downloads_dl_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.database_downloads_dl_id_seq OWNED BY public.database_downloads.dl_id;
--
-- Name: database_licences; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.database_licences (
lic_sha256 text NOT NULL,
friendly_name text NOT NULL,
user_id bigint NOT NULL,
licence_url text,
licence_text text NOT NULL,
display_order integer,
lic_id integer NOT NULL,
full_name text,
file_format text DEFAULT 'text'::text NOT NULL
);
--
-- Name: database_licences_lic_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.database_licences_lic_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: database_licences_lic_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.database_licences_lic_id_seq OWNED BY public.database_licences.lic_id;
--
-- Name: database_shares; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.database_shares (
db_id bigint NOT NULL,
user_id bigint NOT NULL,
date_last_change timestamp with time zone DEFAULT now() NOT NULL,
access public.permissions NOT NULL
);
--
-- Name: database_stars; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.database_stars (
db_id bigint NOT NULL,
user_id bigint NOT NULL,
date_starred timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: database_uploads; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.database_uploads (
up_id bigint NOT NULL,
db_id bigint NOT NULL,
user_id bigint,
ip_addr text NOT NULL,
server_sw text NOT NULL,
user_agent text NOT NULL,
upload_date timestamp with time zone NOT NULL,
db_sha256 text NOT NULL
);
--
-- Name: database_uploads_up_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.database_uploads_up_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: database_uploads_up_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.database_uploads_up_id_seq OWNED BY public.database_uploads.up_id;
--
-- Name: db4s_connects; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.db4s_connects (
connect_id bigint NOT NULL,
user_id integer,
ip_addr text,
user_agent text,
connect_date timestamp with time zone
);
--
-- Name: db4s_connects_connect_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.db4s_connects_connect_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: db4s_connects_connect_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.db4s_connects_connect_id_seq OWNED BY public.db4s_connects.connect_id;
--
-- Name: discussion_comments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.discussion_comments (
com_id bigint NOT NULL,
disc_id bigint NOT NULL,
commenter bigint NOT NULL,
date_created timestamp with time zone DEFAULT now() NOT NULL,
body text NOT NULL,
db_id bigint,
entry_type text DEFAULT 'txt'::text NOT NULL
);
--
-- Name: discussion_comments_com_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.discussion_comments_com_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: discussion_comments_com_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.discussion_comments_com_id_seq OWNED BY public.discussion_comments.com_id;
--
-- Name: discussions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.discussions (
internal_id bigint NOT NULL,
db_id bigint NOT NULL,
creator bigint NOT NULL,
date_created timestamp with time zone DEFAULT now() NOT NULL,
title text NOT NULL,
description text NOT NULL,
open boolean DEFAULT true NOT NULL,
disc_id integer DEFAULT 1 NOT NULL,
last_modified timestamp with time zone DEFAULT now() NOT NULL,
comment_count integer DEFAULT 0 NOT NULL,
discussion_type integer DEFAULT 0 NOT NULL,
mr_source_db_id bigint,
mr_source_db_branch text,
mr_destination_branch text,
mr_state integer DEFAULT 0 NOT NULL,
mr_commits jsonb
);
--
-- Name: COLUMN discussions.mr_source_db_id; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.discussions.mr_source_db_id IS 'Only used by Merge Requests, not standard discussions';
--
-- Name: discussions_disc_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.discussions_disc_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: discussions_disc_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.discussions_disc_id_seq OWNED BY public.discussions.internal_id;
--
-- Name: email_queue; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.email_queue (
email_id bigint NOT NULL,
queued_timestamp timestamp with time zone DEFAULT now() NOT NULL,
mail_to text NOT NULL,
body text NOT NULL,
sent boolean DEFAULT false NOT NULL,
sent_timestamp timestamp with time zone,
subject text NOT NULL
);
--
-- Name: email_queue_email_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.email_queue_email_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: email_queue_email_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.email_queue_email_id_seq OWNED BY public.email_queue.email_id;
--
-- Name: events; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.events (
event_id bigint NOT NULL,
db_id bigint,
event_type integer NOT NULL,
event_data jsonb NOT NULL,
event_timestamp timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: events_event_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.events_event_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: events_event_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.events_event_id_seq OWNED BY public.events.event_id;
--
-- Name: sql_terminal_history; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.sql_terminal_history (
history_id bigint NOT NULL,
user_id bigint NOT NULL,
db_id bigint NOT NULL,
sql_stmt text,
result jsonb,
state text NOT NULL
);
--
-- Name: TABLE sql_terminal_history; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON TABLE public.sql_terminal_history IS 'This table holds the history of executed SQL statements for a user and database';
--
-- Name: sql_terminal_history_history_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.sql_terminal_history_history_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: sql_terminal_history_history_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.sql_terminal_history_history_id_seq OWNED BY public.sql_terminal_history.history_id;
--
-- Name: sqlite_databases; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.sqlite_databases (
user_id bigint NOT NULL,
db_id bigint NOT NULL,
db_name text NOT NULL,
public boolean DEFAULT false NOT NULL,
date_created timestamp with time zone DEFAULT now() NOT NULL,
last_modified timestamp with time zone DEFAULT now() NOT NULL,
watchers bigint DEFAULT 0 NOT NULL,
stars bigint DEFAULT 0 NOT NULL,
forks bigint DEFAULT 0 NOT NULL,
discussions bigint DEFAULT 0 NOT NULL,
merge_requests bigint DEFAULT 0 NOT NULL,
branches bigint DEFAULT 1 NOT NULL,
contributors bigint DEFAULT 1 NOT NULL,
one_line_description text,
full_description text,
root_database bigint,
forked_from bigint,
default_table text,
source_url text,
commit_list jsonb,
branch_heads jsonb,
tag_list jsonb,
default_branch text,
is_deleted boolean DEFAULT false NOT NULL,
tags integer DEFAULT 0 NOT NULL,
release_list jsonb,
release_count integer DEFAULT 0 NOT NULL,
download_count bigint DEFAULT 0,
page_views bigint DEFAULT 0,
live_db boolean DEFAULT false NOT NULL,
live_node text,
live_minio_object_id text
);
--
-- Name: sqlite_databases_db_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.sqlite_databases_db_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: sqlite_databases_db_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.sqlite_databases_db_id_seq OWNED BY public.sqlite_databases.db_id;
--
-- Name: users; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.users (
user_id bigint NOT NULL,
user_name text NOT NULL,
auth0_id text NOT NULL,
email text,
date_joined timestamp with time zone DEFAULT now() NOT NULL,
client_cert bytea NOT NULL,
password_hash text NOT NULL,
pref_max_rows integer DEFAULT 10 NOT NULL,
watchers bigint DEFAULT 0 NOT NULL,
default_licence integer,
display_name text,
avatar_url text,
status_updates jsonb,
live_minio_bucket_name text
);
--
-- Name: users_user_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.users_user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: users_user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.users_user_id_seq OWNED BY public.users.user_id;
--
-- Name: vis_params; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.vis_params (
db_id bigint,
user_id bigint,
name text NOT NULL,
date_created timestamp with time zone DEFAULT now(),
parameters jsonb
);
--
-- Name: vis_query_runs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.vis_query_runs (
query_run_id bigint NOT NULL,
db_id bigint,
user_id bigint,
ip_addr text,
user_agent text,
query_string text,
query_date timestamp with time zone DEFAULT now(),
memory_used bigint,
memory_high_water bigint,
source text
);
--
-- Name: vis_query_runs_query_run_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.vis_query_runs_query_run_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: vis_query_runs_query_run_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.vis_query_runs_query_run_id_seq OWNED BY public.vis_query_runs.query_run_id;
--
-- Name: watchers; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.watchers (
db_id bigint NOT NULL,
user_id bigint NOT NULL,
date_watched timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: api_call_log api_call_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.api_call_log ALTER COLUMN api_call_id SET DEFAULT nextval('public.api_log_log_id_seq'::regclass);
--
-- Name: api_keys key_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.api_keys ALTER COLUMN key_id SET DEFAULT nextval('public.api_keys_key_id_seq'::regclass);
--
-- Name: database_downloads dl_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.database_downloads ALTER COLUMN dl_id SET DEFAULT nextval('public.database_downloads_dl_id_seq'::regclass);
--
-- Name: database_licences lic_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.database_licences ALTER COLUMN lic_id SET DEFAULT nextval('public.database_licences_lic_id_seq'::regclass);
--
-- Name: database_uploads up_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.database_uploads ALTER COLUMN up_id SET DEFAULT nextval('public.database_uploads_up_id_seq'::regclass);
--
-- Name: db4s_connects connect_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.db4s_connects ALTER COLUMN connect_id SET DEFAULT nextval('public.db4s_connects_connect_id_seq'::regclass);
--
-- Name: discussion_comments com_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.discussion_comments ALTER COLUMN com_id SET DEFAULT nextval('public.discussion_comments_com_id_seq'::regclass);
--
-- Name: discussions internal_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.discussions ALTER COLUMN internal_id SET DEFAULT nextval('public.discussions_disc_id_seq'::regclass);
--
-- Name: email_queue email_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.email_queue ALTER COLUMN email_id SET DEFAULT nextval('public.email_queue_email_id_seq'::regclass);
--
-- Name: events event_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.events ALTER COLUMN event_id SET DEFAULT nextval('public.events_event_id_seq'::regclass);
--
-- Name: sql_terminal_history history_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.sql_terminal_history ALTER COLUMN history_id SET DEFAULT nextval('public.sql_terminal_history_history_id_seq'::regclass);
--
-- Name: sqlite_databases db_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.sqlite_databases ALTER COLUMN db_id SET DEFAULT nextval('public.sqlite_databases_db_id_seq'::regclass);
--
-- Name: users user_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users ALTER COLUMN user_id SET DEFAULT nextval('public.users_user_id_seq'::regclass);
--
-- Name: vis_query_runs query_run_id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.vis_query_runs ALTER COLUMN query_run_id SET DEFAULT nextval('public.vis_query_runs_query_run_id_seq'::regclass);
--
-- Name: api_keys api_keys_pk; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.api_keys
ADD CONSTRAINT api_keys_pk PRIMARY KEY (key);
--
-- Name: database_downloads database_downloads_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.database_downloads
ADD CONSTRAINT database_downloads_pkey PRIMARY KEY (dl_id);
--
-- Name: database_licences database_licences_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.database_licences
ADD CONSTRAINT database_licences_pkey PRIMARY KEY (user_id, friendly_name);
--
-- Name: database_shares database_shares_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.database_shares
ADD CONSTRAINT database_shares_pkey PRIMARY KEY (db_id, user_id);
--
-- Name: database_stars database_stars_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.database_stars
ADD CONSTRAINT database_stars_pkey PRIMARY KEY (db_id, user_id);
--
-- Name: database_uploads database_uploads_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.database_uploads
ADD CONSTRAINT database_uploads_pkey PRIMARY KEY (up_id);
--
-- Name: discussion_comments discussion_comments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.discussion_comments
ADD CONSTRAINT discussion_comments_pkey PRIMARY KEY (com_id);
--
-- Name: discussions discussions_db_id_disc_id_unique; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.discussions
ADD CONSTRAINT discussions_db_id_disc_id_unique UNIQUE (db_id, disc_id);
--
-- Name: discussions discussions_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.discussions
ADD CONSTRAINT discussions_pkey PRIMARY KEY (internal_id);
--
-- Name: email_queue email_queue_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.email_queue
ADD CONSTRAINT email_queue_pkey PRIMARY KEY (email_id);
--
-- Name: events events_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.events
ADD CONSTRAINT events_pkey PRIMARY KEY (event_id);
--
-- Name: sqlite_databases sqlite_databases_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.sqlite_databases
ADD CONSTRAINT sqlite_databases_pkey PRIMARY KEY (db_id);
--
-- Name: sqlite_databases sqlite_databases_user_id_db_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.sqlite_databases
ADD CONSTRAINT sqlite_databases_user_id_db_name_key UNIQUE (user_id, db_name);
--
-- Name: users users_auth0_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_auth0_id_key UNIQUE (auth0_id);
--
-- Name: users users_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_pkey PRIMARY KEY (user_id);
--
-- Name: users users_user_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.users
ADD CONSTRAINT users_user_name_key UNIQUE (user_name);
--
-- Name: vis_params vis_params_pk; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.vis_params
ADD CONSTRAINT vis_params_pk UNIQUE (db_id, user_id, name);
--
-- Name: vis_query_runs vis_query_runs_pk; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.vis_query_runs
ADD CONSTRAINT vis_query_runs_pk PRIMARY KEY (query_run_id);
--
-- Name: watchers watchers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.watchers
ADD CONSTRAINT watchers_pkey PRIMARY KEY (db_id, user_id);
--
-- Name: api_keys_key_uindex; Type: INDEX; Schema: public; Owner: -
--
CREATE UNIQUE INDEX api_keys_key_uindex ON public.api_keys USING btree (key);
--
-- Name: database_licences_lic_id_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX database_licences_lic_id_idx ON public.database_licences USING btree (lic_id);
--
-- Name: database_licences_lic_sha256_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX database_licences_lic_sha256_idx ON public.database_licences USING btree (lic_sha256);
--
-- Name: database_licences_user_id_friendly_name_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX database_licences_user_id_friendly_name_idx ON public.database_licences USING btree (user_id, friendly_name);
--
-- Name: db4s_connects_connect_date_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX db4s_connects_connect_date_index ON public.db4s_connects USING btree (connect_date);
--
-- Name: db4s_connects_user_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX db4s_connects_user_id_index ON public.db4s_connects USING btree (user_id);
--
-- Name: discussions_discussion_type_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX discussions_discussion_type_idx ON public.discussions USING btree (discussion_type);
--
-- Name: events_event_id_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX events_event_id_idx ON public.events USING btree (event_id);
--
-- Name: fki_database_downloads_db_id_fkey; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fki_database_downloads_db_id_fkey ON public.database_downloads USING btree (db_id);
--
-- Name: fki_database_downloads_user_id_fkey; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fki_database_downloads_user_id_fkey ON public.database_downloads USING btree (user_id);
--
-- Name: fki_database_uploads_db_id_fkey; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fki_database_uploads_db_id_fkey ON public.database_uploads USING btree (db_id);
--
-- Name: fki_database_uploads_user_id_fkey; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fki_database_uploads_user_id_fkey ON public.database_uploads USING btree (user_id);
--
-- Name: fki_discussion_comments_db_id_fkey; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fki_discussion_comments_db_id_fkey ON public.discussion_comments USING btree (db_id);
--
-- Name: fki_discussions_source_db_id_fkey; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX fki_discussions_source_db_id_fkey ON public.discussions USING btree (mr_source_db_id);
--
-- Name: sql_terminal_history_user_id_db_id_index; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX sql_terminal_history_user_id_db_id_index ON public.sql_terminal_history USING btree (user_id, db_id);
--
-- Name: users_lower_user_name_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX users_lower_user_name_idx ON public.users USING btree (lower(user_name));
--
-- Name: users_user_id_idx; Type: INDEX; Schema: public; Owner: -
--
CREATE INDEX users_user_id_idx ON public.users USING btree (user_id);