summaryrefslogtreecommitdiffstats
path: root/python/schema.sql
blob: ec38bcb3597e4b415bdeb54476edbc9ec80ef5b1 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078


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 client_min_messages = warning;
SET row_security = off;


COMMENT ON DATABASE postgres IS 'default administrative connection database';



CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;



COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';


SET default_tablespace = '';

SET default_with_oids = false;


CREATE TABLE public.changelog (
    id integer NOT NULL,
    editgroup_id integer,
    "timestamp" integer
);


ALTER TABLE public.changelog OWNER TO postgres;


CREATE SEQUENCE public.changelog_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.changelog_id_seq OWNER TO postgres;


ALTER SEQUENCE public.changelog_id_seq OWNED BY public.changelog.id;



CREATE TABLE public.container_edit (
    id integer NOT NULL,
    ident_id integer,
    rev_id integer,
    redirect_id integer,
    editgroup_id integer,
    extra_json_id character varying
);


ALTER TABLE public.container_edit OWNER TO postgres;


CREATE SEQUENCE public.container_edit_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.container_edit_id_seq OWNER TO postgres;


ALTER SEQUENCE public.container_edit_id_seq OWNED BY public.container_edit.id;



CREATE TABLE public.container_ident (
    id integer NOT NULL,
    is_live boolean NOT NULL,
    rev_id integer,
    redirect_id integer
);


ALTER TABLE public.container_ident OWNER TO postgres;


CREATE SEQUENCE public.container_ident_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.container_ident_id_seq OWNER TO postgres;


ALTER SEQUENCE public.container_ident_id_seq OWNED BY public.container_ident.id;



CREATE TABLE public.container_rev (
    id integer NOT NULL,
    extra_json_id character varying,
    name character varying,
    parent_id integer,
    publisher character varying,
    sortname character varying,
    issn character varying
);


ALTER TABLE public.container_rev OWNER TO postgres;


CREATE SEQUENCE public.container_rev_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.container_rev_id_seq OWNER TO postgres;


ALTER SEQUENCE public.container_rev_id_seq OWNED BY public.container_rev.id;



CREATE TABLE public.creator_edit (
    id integer NOT NULL,
    ident_id integer,
    rev_id integer,
    redirect_id integer,
    editgroup_id integer,
    extra_json_id character varying
);


ALTER TABLE public.creator_edit OWNER TO postgres;


CREATE SEQUENCE public.creator_edit_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.creator_edit_id_seq OWNER TO postgres;


ALTER SEQUENCE public.creator_edit_id_seq OWNED BY public.creator_edit.id;



CREATE TABLE public.creator_ident (
    id integer NOT NULL,
    is_live boolean NOT NULL,
    rev_id integer,
    redirect_id integer
);


ALTER TABLE public.creator_ident OWNER TO postgres;


CREATE SEQUENCE public.creator_ident_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.creator_ident_id_seq OWNER TO postgres;


ALTER SEQUENCE public.creator_ident_id_seq OWNED BY public.creator_ident.id;



CREATE TABLE public.creator_rev (
    id integer NOT NULL,
    extra_json_id character varying,
    name character varying,
    sortname character varying,
    orcid character varying
);


ALTER TABLE public.creator_rev OWNER TO postgres;


CREATE SEQUENCE public.creator_rev_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.creator_rev_id_seq OWNER TO postgres;


ALTER SEQUENCE public.creator_rev_id_seq OWNED BY public.creator_rev.id;



CREATE TABLE public.editgroup (
    id integer NOT NULL,
    editor_id integer NOT NULL,
    description character varying,
    extra_json_id character varying
);


ALTER TABLE public.editgroup OWNER TO postgres;


CREATE SEQUENCE public.editgroup_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.editgroup_id_seq OWNER TO postgres;


ALTER SEQUENCE public.editgroup_id_seq OWNED BY public.editgroup.id;



CREATE TABLE public.editor (
    id integer NOT NULL,
    username character varying NOT NULL,
    is_admin boolean NOT NULL,
    active_editgroup_id integer
);


ALTER TABLE public.editor OWNER TO postgres;


CREATE SEQUENCE public.editor_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.editor_id_seq OWNER TO postgres;


ALTER SEQUENCE public.editor_id_seq OWNED BY public.editor.id;



CREATE TABLE public.extra_json (
    sha1 character varying NOT NULL,
    json character varying NOT NULL
);


ALTER TABLE public.extra_json OWNER TO postgres;


CREATE TABLE public.file_edit (
    id integer NOT NULL,
    ident_id integer,
    rev_id integer,
    redirect_id integer,
    editgroup_id integer,
    extra_json_id character varying
);


ALTER TABLE public.file_edit OWNER TO postgres;


CREATE SEQUENCE public.file_edit_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.file_edit_id_seq OWNER TO postgres;


ALTER SEQUENCE public.file_edit_id_seq OWNED BY public.file_edit.id;



CREATE TABLE public.file_ident (
    id integer NOT NULL,
    is_live boolean NOT NULL,
    rev_id integer,
    redirect_id integer
);


ALTER TABLE public.file_ident OWNER TO postgres;


CREATE SEQUENCE public.file_ident_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.file_ident_id_seq OWNER TO postgres;


ALTER SEQUENCE public.file_ident_id_seq OWNED BY public.file_ident.id;



CREATE TABLE public.file_release (
    id integer NOT NULL,
    file_rev integer NOT NULL,
    release_ident_id integer NOT NULL
);


ALTER TABLE public.file_release OWNER TO postgres;


CREATE SEQUENCE public.file_release_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.file_release_id_seq OWNER TO postgres;


ALTER SEQUENCE public.file_release_id_seq OWNED BY public.file_release.id;



CREATE TABLE public.file_rev (
    id integer NOT NULL,
    extra_json_id character varying,
    size integer,
    sha1 character varying,
    url integer
);


ALTER TABLE public.file_rev OWNER TO postgres;


CREATE SEQUENCE public.file_rev_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.file_rev_id_seq OWNER TO postgres;


ALTER SEQUENCE public.file_rev_id_seq OWNED BY public.file_rev.id;



CREATE TABLE public.release_contrib (
    release_rev integer NOT NULL,
    creator_ident_id integer NOT NULL,
    stub character varying,
    type character varying
);


ALTER TABLE public.release_contrib OWNER TO postgres;


CREATE TABLE public.release_edit (
    id integer NOT NULL,
    ident_id integer,
    rev_id integer,
    redirect_id integer,
    editgroup_id integer,
    extra_json_id character varying
);


ALTER TABLE public.release_edit OWNER TO postgres;


CREATE SEQUENCE public.release_edit_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.release_edit_id_seq OWNER TO postgres;


ALTER SEQUENCE public.release_edit_id_seq OWNED BY public.release_edit.id;



CREATE TABLE public.release_ident (
    id integer NOT NULL,
    is_live boolean NOT NULL,
    rev_id integer,
    redirect_id integer
);


ALTER TABLE public.release_ident OWNER TO postgres;


CREATE SEQUENCE public.release_ident_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.release_ident_id_seq OWNER TO postgres;


ALTER SEQUENCE public.release_ident_id_seq OWNED BY public.release_ident.id;



CREATE TABLE public.release_ref (
    id integer NOT NULL,
    release_rev integer NOT NULL,
    target_release_ident_id integer,
    index integer,
    stub character varying,
    doi character varying
);


ALTER TABLE public.release_ref OWNER TO postgres;


CREATE SEQUENCE public.release_ref_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.release_ref_id_seq OWNER TO postgres;


ALTER SEQUENCE public.release_ref_id_seq OWNED BY public.release_ref.id;



CREATE TABLE public.release_rev (
    id integer NOT NULL,
    extra_json_id character varying,
    work_ident_id integer,
    container_ident_id integer,
    title character varying NOT NULL,
    license character varying,
    release_type character varying,
    date character varying,
    doi character varying,
    volume character varying,
    pages character varying,
    issue character varying
);


ALTER TABLE public.release_rev OWNER TO postgres;


CREATE SEQUENCE public.release_rev_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.release_rev_id_seq OWNER TO postgres;


ALTER SEQUENCE public.release_rev_id_seq OWNED BY public.release_rev.id;



CREATE TABLE public.work_edit (
    id integer NOT NULL,
    ident_id integer,
    rev_id integer,
    redirect_id integer,
    editgroup_id integer,
    extra_json_id character varying
);


ALTER TABLE public.work_edit OWNER TO postgres;


CREATE SEQUENCE public.work_edit_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.work_edit_id_seq OWNER TO postgres;


ALTER SEQUENCE public.work_edit_id_seq OWNED BY public.work_edit.id;



CREATE TABLE public.work_ident (
    id integer NOT NULL,
    is_live boolean NOT NULL,
    rev_id integer,
    redirect_id integer
);


ALTER TABLE public.work_ident OWNER TO postgres;


CREATE SEQUENCE public.work_ident_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.work_ident_id_seq OWNER TO postgres;


ALTER SEQUENCE public.work_ident_id_seq OWNED BY public.work_ident.id;



CREATE TABLE public.work_rev (
    id integer NOT NULL,
    extra_json_id character varying,
    title character varying,
    work_type character varying,
    primary_release_id integer
);


ALTER TABLE public.work_rev OWNER TO postgres;


CREATE SEQUENCE public.work_rev_id_seq
    AS integer
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER TABLE public.work_rev_id_seq OWNER TO postgres;


ALTER SEQUENCE public.work_rev_id_seq OWNED BY public.work_rev.id;



ALTER TABLE ONLY public.changelog ALTER COLUMN id SET DEFAULT nextval('public.changelog_id_seq'::regclass);



ALTER TABLE ONLY public.container_edit ALTER COLUMN id SET DEFAULT nextval('public.container_edit_id_seq'::regclass);



ALTER TABLE ONLY public.container_ident ALTER COLUMN id SET DEFAULT nextval('public.container_ident_id_seq'::regclass);



ALTER TABLE ONLY public.container_rev ALTER COLUMN id SET DEFAULT nextval('public.container_rev_id_seq'::regclass);



ALTER TABLE ONLY public.creator_edit ALTER COLUMN id SET DEFAULT nextval('public.creator_edit_id_seq'::regclass);



ALTER TABLE ONLY public.creator_ident ALTER COLUMN id SET DEFAULT nextval('public.creator_ident_id_seq'::regclass);



ALTER TABLE ONLY public.creator_rev ALTER COLUMN id SET DEFAULT nextval('public.creator_rev_id_seq'::regclass);



ALTER TABLE ONLY public.editgroup ALTER COLUMN id SET DEFAULT nextval('public.editgroup_id_seq'::regclass);



ALTER TABLE ONLY public.editor ALTER COLUMN id SET DEFAULT nextval('public.editor_id_seq'::regclass);



ALTER TABLE ONLY public.file_edit ALTER COLUMN id SET DEFAULT nextval('public.file_edit_id_seq'::regclass);



ALTER TABLE ONLY public.file_ident ALTER COLUMN id SET DEFAULT nextval('public.file_ident_id_seq'::regclass);



ALTER TABLE ONLY public.file_release ALTER COLUMN id SET DEFAULT nextval('public.file_release_id_seq'::regclass);



ALTER TABLE ONLY public.file_rev ALTER COLUMN id SET DEFAULT nextval('public.file_rev_id_seq'::regclass);



ALTER TABLE ONLY public.release_edit ALTER COLUMN id SET DEFAULT nextval('public.release_edit_id_seq'::regclass);



ALTER TABLE ONLY public.release_ident ALTER COLUMN id SET DEFAULT nextval('public.release_ident_id_seq'::regclass);



ALTER TABLE ONLY public.release_ref ALTER COLUMN id SET DEFAULT nextval('public.release_ref_id_seq'::regclass);



ALTER TABLE ONLY public.release_rev ALTER COLUMN id SET DEFAULT nextval('public.release_rev_id_seq'::regclass);



ALTER TABLE ONLY public.work_edit ALTER COLUMN id SET DEFAULT nextval('public.work_edit_id_seq'::regclass);



ALTER TABLE ONLY public.work_ident ALTER COLUMN id SET DEFAULT nextval('public.work_ident_id_seq'::regclass);



ALTER TABLE ONLY public.work_rev ALTER COLUMN id SET DEFAULT nextval('public.work_rev_id_seq'::regclass);



ALTER TABLE ONLY public.changelog
    ADD CONSTRAINT changelog_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.container_edit
    ADD CONSTRAINT container_edit_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.container_ident
    ADD CONSTRAINT container_ident_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.container_rev
    ADD CONSTRAINT container_rev_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.creator_edit
    ADD CONSTRAINT creator_edit_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.creator_ident
    ADD CONSTRAINT creator_ident_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.creator_rev
    ADD CONSTRAINT creator_rev_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.editgroup
    ADD CONSTRAINT editgroup_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.editor
    ADD CONSTRAINT editor_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.editor
    ADD CONSTRAINT editor_username_key UNIQUE (username);



ALTER TABLE ONLY public.extra_json
    ADD CONSTRAINT extra_json_pkey PRIMARY KEY (sha1);



ALTER TABLE ONLY public.file_edit
    ADD CONSTRAINT file_edit_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.file_ident
    ADD CONSTRAINT file_ident_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.file_release
    ADD CONSTRAINT file_release_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.file_rev
    ADD CONSTRAINT file_rev_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.release_contrib
    ADD CONSTRAINT release_contrib_pkey PRIMARY KEY (release_rev, creator_ident_id);



ALTER TABLE ONLY public.release_edit
    ADD CONSTRAINT release_edit_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.release_ident
    ADD CONSTRAINT release_ident_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.release_ref
    ADD CONSTRAINT release_ref_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.release_rev
    ADD CONSTRAINT release_rev_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.work_edit
    ADD CONSTRAINT work_edit_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.work_ident
    ADD CONSTRAINT work_ident_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.work_rev
    ADD CONSTRAINT work_rev_pkey PRIMARY KEY (id);



ALTER TABLE ONLY public.changelog
    ADD CONSTRAINT changelog_editgroup_id_fkey FOREIGN KEY (editgroup_id) REFERENCES public.editgroup(id);



ALTER TABLE ONLY public.container_edit
    ADD CONSTRAINT container_edit_editgroup_id_fkey FOREIGN KEY (editgroup_id) REFERENCES public.editgroup(id);



ALTER TABLE ONLY public.container_edit
    ADD CONSTRAINT container_edit_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.container_edit
    ADD CONSTRAINT container_edit_ident_id_fkey FOREIGN KEY (ident_id) REFERENCES public.container_ident(id);



ALTER TABLE ONLY public.container_edit
    ADD CONSTRAINT container_edit_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.container_ident(id);



ALTER TABLE ONLY public.container_edit
    ADD CONSTRAINT container_edit_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.container_rev(id);



ALTER TABLE ONLY public.container_ident
    ADD CONSTRAINT container_ident_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.container_ident(id);



ALTER TABLE ONLY public.container_ident
    ADD CONSTRAINT container_ident_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.container_rev(id);



ALTER TABLE ONLY public.container_rev
    ADD CONSTRAINT container_rev_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.container_rev
    ADD CONSTRAINT container_rev_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES public.container_ident(id);



ALTER TABLE ONLY public.creator_edit
    ADD CONSTRAINT creator_edit_editgroup_id_fkey FOREIGN KEY (editgroup_id) REFERENCES public.editgroup(id);



ALTER TABLE ONLY public.creator_edit
    ADD CONSTRAINT creator_edit_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.creator_edit
    ADD CONSTRAINT creator_edit_ident_id_fkey FOREIGN KEY (ident_id) REFERENCES public.creator_ident(id);



ALTER TABLE ONLY public.creator_edit
    ADD CONSTRAINT creator_edit_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.creator_ident(id);



ALTER TABLE ONLY public.creator_edit
    ADD CONSTRAINT creator_edit_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.creator_rev(id);



ALTER TABLE ONLY public.creator_ident
    ADD CONSTRAINT creator_ident_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.creator_ident(id);



ALTER TABLE ONLY public.creator_ident
    ADD CONSTRAINT creator_ident_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.creator_rev(id);



ALTER TABLE ONLY public.creator_rev
    ADD CONSTRAINT creator_rev_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.editgroup
    ADD CONSTRAINT editgroup_editor_id_fkey FOREIGN KEY (editor_id) REFERENCES public.editor(id);



ALTER TABLE ONLY public.editgroup
    ADD CONSTRAINT editgroup_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.editor
    ADD CONSTRAINT editor_active_editgroup_id_fkey FOREIGN KEY (active_editgroup_id) REFERENCES public.editgroup(id);



ALTER TABLE ONLY public.file_edit
    ADD CONSTRAINT file_edit_editgroup_id_fkey FOREIGN KEY (editgroup_id) REFERENCES public.editgroup(id);



ALTER TABLE ONLY public.file_edit
    ADD CONSTRAINT file_edit_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.file_edit
    ADD CONSTRAINT file_edit_ident_id_fkey FOREIGN KEY (ident_id) REFERENCES public.file_ident(id);



ALTER TABLE ONLY public.file_edit
    ADD CONSTRAINT file_edit_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.file_ident(id);



ALTER TABLE ONLY public.file_edit
    ADD CONSTRAINT file_edit_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.file_rev(id);



ALTER TABLE ONLY public.file_ident
    ADD CONSTRAINT file_ident_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.file_ident(id);



ALTER TABLE ONLY public.file_ident
    ADD CONSTRAINT file_ident_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.file_rev(id);



ALTER TABLE ONLY public.file_release
    ADD CONSTRAINT file_release_file_rev_fkey FOREIGN KEY (file_rev) REFERENCES public.file_rev(id);



ALTER TABLE ONLY public.file_release
    ADD CONSTRAINT file_release_release_ident_id_fkey FOREIGN KEY (release_ident_id) REFERENCES public.release_ident(id);



ALTER TABLE ONLY public.file_rev
    ADD CONSTRAINT file_rev_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.release_contrib
    ADD CONSTRAINT release_contrib_creator_ident_id_fkey FOREIGN KEY (creator_ident_id) REFERENCES public.creator_ident(id);



ALTER TABLE ONLY public.release_contrib
    ADD CONSTRAINT release_contrib_release_rev_fkey FOREIGN KEY (release_rev) REFERENCES public.release_rev(id);



ALTER TABLE ONLY public.release_edit
    ADD CONSTRAINT release_edit_editgroup_id_fkey FOREIGN KEY (editgroup_id) REFERENCES public.editgroup(id);



ALTER TABLE ONLY public.release_edit
    ADD CONSTRAINT release_edit_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.release_edit
    ADD CONSTRAINT release_edit_ident_id_fkey FOREIGN KEY (ident_id) REFERENCES public.release_ident(id);



ALTER TABLE ONLY public.release_edit
    ADD CONSTRAINT release_edit_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.release_ident(id);



ALTER TABLE ONLY public.release_edit
    ADD CONSTRAINT release_edit_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.release_rev(id);



ALTER TABLE ONLY public.release_ident
    ADD CONSTRAINT release_ident_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.release_ident(id);



ALTER TABLE ONLY public.release_ident
    ADD CONSTRAINT release_ident_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.release_rev(id);



ALTER TABLE ONLY public.release_ref
    ADD CONSTRAINT release_ref_release_rev_fkey FOREIGN KEY (release_rev) REFERENCES public.release_rev(id);



ALTER TABLE ONLY public.release_ref
    ADD CONSTRAINT release_ref_target_release_ident_id_fkey FOREIGN KEY (target_release_ident_id) REFERENCES public.release_ident(id);



ALTER TABLE ONLY public.release_rev
    ADD CONSTRAINT release_rev_container_ident_id_fkey FOREIGN KEY (container_ident_id) REFERENCES public.container_ident(id);



ALTER TABLE ONLY public.release_rev
    ADD CONSTRAINT release_rev_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.release_rev
    ADD CONSTRAINT release_rev_work_ident_id_fkey FOREIGN KEY (work_ident_id) REFERENCES public.work_ident(id);



ALTER TABLE ONLY public.work_edit
    ADD CONSTRAINT work_edit_editgroup_id_fkey FOREIGN KEY (editgroup_id) REFERENCES public.editgroup(id);



ALTER TABLE ONLY public.work_edit
    ADD CONSTRAINT work_edit_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.work_edit
    ADD CONSTRAINT work_edit_ident_id_fkey FOREIGN KEY (ident_id) REFERENCES public.work_ident(id);



ALTER TABLE ONLY public.work_edit
    ADD CONSTRAINT work_edit_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.work_ident(id);



ALTER TABLE ONLY public.work_edit
    ADD CONSTRAINT work_edit_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.work_rev(id);



ALTER TABLE ONLY public.work_ident
    ADD CONSTRAINT work_ident_redirect_id_fkey FOREIGN KEY (redirect_id) REFERENCES public.work_ident(id);



ALTER TABLE ONLY public.work_ident
    ADD CONSTRAINT work_ident_rev_id_fkey FOREIGN KEY (rev_id) REFERENCES public.work_rev(id);



ALTER TABLE ONLY public.work_rev
    ADD CONSTRAINT work_rev_extra_json_id_fkey FOREIGN KEY (extra_json_id) REFERENCES public.extra_json(sha1);



ALTER TABLE ONLY public.work_rev
    ADD CONSTRAINT work_rev_primary_release_id_fkey FOREIGN KEY (primary_release_id) REFERENCES public.release_ident(id);