-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateTables.sql
More file actions
4660 lines (4014 loc) · 181 KB
/
Copy pathCreateTables.sql
File metadata and controls
4660 lines (4014 loc) · 181 KB
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
--
-- File generated with SQLiteStudio v3.2.1 on So Mai 5 13:58:07 2019
--
-- Adapted from https://github.com/metabrainz/musicbrainz-server/blob/master/admin/sql/CreateTables.sql
--
-- Text encoding used: UTF-8
--
PRAGMA foreign_keys = off;
BEGIN TRANSACTION;
-- Table: alternative_medium
CREATE TABLE alternative_medium (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
medium INTEGER NOT NULL,-- FK, references medium.id
alternative_release INTEGER NOT NULL,-- references alternative_release.id
name VARCHAR CHECK (name != '')
);
-- Table: alternative_medium_track
CREATE TABLE alternative_medium_track (-- replicate
alternative_medium INTEGER NOT NULL,-- PK, references alternative_medium.id
track INTEGER NOT NULL,-- PK, references track.id
alternative_track INTEGER NOT NULL-- references alternative_track.id
);
-- Table: alternative_release
CREATE TABLE alternative_release (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
gid TEXT NOT NULL,
[release] INTEGER NOT NULL,-- references release.id
name VARCHAR,
artist_credit INTEGER,-- references artist_credit.id
type INTEGER NOT NULL,-- references alternative_release_type.id
language INTEGER NOT NULL,-- references language.id
script INTEGER NOT NULL,-- references script.id
comment VARCHAR (255) NOT NULL
DEFAULT ''
CHECK (name != '')
);
-- Table: alternative_release_type
CREATE TABLE alternative_release_type (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
name TEXT NOT NULL,
parent INTEGER,-- references alternative_release_type.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: alternative_track
CREATE TABLE alternative_track (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
name VARCHAR,
artist_credit INTEGER,-- references artist_credit.id
ref_count INTEGER NOT NULL
DEFAULT 0
CHECK (name != '' AND
(name IS NOT NULL OR
artist_credit IS NOT NULL) )
);
-- Table: annotation
CREATE TABLE annotation (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id
text TEXT,
changelog VARCHAR (255),
created TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: application
CREATE TABLE application (
id INTEGER PRIMARY KEY AUTOINCREMENT,
owner INTEGER NOT NULL,-- references editor.id
name TEXT NOT NULL,
oauth_id TEXT NOT NULL,
oauth_secret TEXT NOT NULL,
oauth_redirect_uri TEXT
);
-- Table: area
CREATE TABLE area (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
gid TEXT NOT NULL,
name VARCHAR NOT NULL,
type INTEGER,-- references area_type.id
edits_pending INTEGER NOT NULL
DEFAULT 0
CHECK (edits_pending >= 0),
last_updated TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
begin_date_year INTEGER,
begin_date_month INTEGER,
begin_date_day INTEGER,
end_date_year INTEGER,
end_date_month INTEGER,
end_date_day INTEGER,
ended BOOLEAN NOT NULL
DEFAULT FALSE
CHECK ( (/* If any end date fields are not null, then ended must be true */ (end_date_year IS NOT NULL OR
end_date_month IS NOT NULL OR
end_date_day IS NOT NULL) AND
ended = TRUE) OR
(/* Otherwise, all end date fields must be null */ (end_date_year IS NULL AND
end_date_month IS NULL AND
end_date_day IS NULL) ) ),
comment VARCHAR (255) NOT NULL
DEFAULT ''
);
-- Table: area_alias
CREATE TABLE area_alias (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
area INTEGER NOT NULL,-- references area.id
name VARCHAR NOT NULL,
locale TEXT,
edits_pending INTEGER NOT NULL
DEFAULT 0
CHECK (edits_pending >= 0),
last_updated TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
type INTEGER,-- references area_alias_type.id
sort_name VARCHAR NOT NULL,
begin_date_year INTEGER,
begin_date_month INTEGER,
begin_date_day INTEGER,
end_date_year INTEGER,
end_date_month INTEGER,
end_date_day INTEGER,
primary_for_locale BOOLEAN NOT NULL
DEFAULT FALSE,
ended BOOLEAN NOT NULL
DEFAULT FALSE
CHECK ( (/* If any end date fields are not null, then ended must be true */ (end_date_year IS NOT NULL OR
end_date_month IS NOT NULL OR
end_date_day IS NOT NULL) AND
ended = TRUE) OR
(/* Otherwise, all end date fields must be null */ (end_date_year IS NULL AND
end_date_month IS NULL AND
end_date_day IS NULL) ) ),
CONSTRAINT primary_check CHECK ( (locale IS NULL AND
primary_for_locale IS FALSE) OR
(locale IS NOT NULL) )
);
-- Table: area_alias_type
CREATE TABLE area_alias_type (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK,
name TEXT NOT NULL,
parent INTEGER,-- references area_alias_type.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: area_annotation
CREATE TABLE area_annotation (-- replicate (verbose)
area INTEGER NOT NULL,-- PK, references area.id
annotation INTEGER NOT NULL-- PK, references annotation.id
);
-- Table: area_attribute
CREATE TABLE area_attribute (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
area INTEGER NOT NULL,-- references area.id
area_attribute_type INTEGER NOT NULL,-- references area_attribute_type.id
area_attribute_type_allowed_value INTEGER,-- references area_attribute_type_allowed_value.id
area_attribute_text TEXT CHECK ( (area_attribute_type_allowed_value IS NULL AND
area_attribute_text IS NOT NULL) OR
(area_attribute_type_allowed_value IS NOT NULL AND
area_attribute_text IS NULL) )
);
-- Table: area_attribute_type
CREATE TABLE area_attribute_type (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
name VARCHAR (255) NOT NULL,
comment VARCHAR (255) NOT NULL
DEFAULT '',
free_text BOOLEAN NOT NULL,
parent INTEGER,-- references area_attribute_type.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: area_attribute_type_allowed_value
CREATE TABLE area_attribute_type_allowed_value (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
area_attribute_type INTEGER NOT NULL,-- references area_attribute_type.id
value TEXT,
parent INTEGER,-- references area_attribute_type_allowed_value.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: area_gid_redirect
CREATE TABLE area_gid_redirect (-- replicate (verbose)
gid TEXT NOT NULL,-- PK
new_id INTEGER NOT NULL,-- references area.id
created TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: area_tag
CREATE TABLE area_tag (-- replicate (verbose)
area INTEGER NOT NULL,-- PK, references area.id
tag INTEGER NOT NULL,-- PK, references tag.id
count INTEGER NOT NULL,
last_updated TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: area_tag_raw
CREATE TABLE area_tag_raw (
area INTEGER NOT NULL,-- PK, references area.id
editor INTEGER NOT NULL,-- PK, references editor.id
tag INTEGER NOT NULL,-- PK, references tag.id
is_upvote BOOLEAN NOT NULL
DEFAULT TRUE
);
-- Table: area_type
CREATE TABLE area_type (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
name VARCHAR (255) NOT NULL,
parent INTEGER,-- references area_type.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: artist
CREATE TABLE artist (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,
gid TEXT NOT NULL,
name VARCHAR NOT NULL,
sort_name VARCHAR NOT NULL,
begin_date_year INTEGER,
begin_date_month INTEGER,
begin_date_day INTEGER,
end_date_year INTEGER,
end_date_month INTEGER,
end_date_day INTEGER,
type INTEGER,-- references artist_type.id
area INTEGER,-- references area.id
gender INTEGER,-- references gender.id
comment VARCHAR (255) NOT NULL
DEFAULT '',
edits_pending INTEGER NOT NULL
DEFAULT 0
CHECK (edits_pending >= 0),
last_updated TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
ended BOOLEAN NOT NULL
DEFAULT FALSE
CONSTRAINT artist_ended_check CHECK ( (/* If any end date fields are not null, then ended must be true */ (end_date_year IS NOT NULL OR
end_date_month IS NOT NULL OR
end_date_day IS NOT NULL) AND
ended = TRUE) OR
(/* Otherwise, all end date fields must be null */ (end_date_year IS NULL AND
end_date_month IS NULL AND
end_date_day IS NULL) ) ),
begin_area INTEGER,-- references area.id
end_area INTEGER-- references area.id
);
-- Table: artist_alias
CREATE TABLE artist_alias (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,
artist INTEGER NOT NULL,-- references artist.id
name VARCHAR NOT NULL,
locale TEXT,
edits_pending INTEGER NOT NULL
DEFAULT 0
CHECK (edits_pending >= 0),
last_updated TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
type INTEGER,-- references artist_alias_type.id
sort_name VARCHAR NOT NULL,
begin_date_year INTEGER,
begin_date_month INTEGER,
begin_date_day INTEGER,
end_date_year INTEGER,
end_date_month INTEGER,
end_date_day INTEGER,
primary_for_locale BOOLEAN NOT NULL
DEFAULT false,
ended BOOLEAN NOT NULL
DEFAULT FALSE
CHECK ( (/* If any end date fields are not null, then ended must be true */ (end_date_year IS NOT NULL OR
end_date_month IS NOT NULL OR
end_date_day IS NOT NULL) AND
ended = TRUE) OR
(/* Otherwise, all end date fields must be null */ (end_date_year IS NULL AND
end_date_month IS NULL AND
end_date_day IS NULL) ) ),
CONSTRAINT primary_check CHECK ( (locale IS NULL AND
primary_for_locale IS FALSE) OR
(locale IS NOT NULL) ),
CONSTRAINT search_hints_are_empty CHECK ( (type <> 3) OR
(type = 3 AND
sort_name = name AND
begin_date_year IS NULL AND
begin_date_month IS NULL AND
begin_date_day IS NULL AND
end_date_year IS NULL AND
end_date_month IS NULL AND
end_date_day IS NULL AND
primary_for_locale IS FALSE AND
locale IS NULL) )
);
-- Table: artist_alias_type
CREATE TABLE artist_alias_type (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
parent INTEGER,-- references artist_alias_type.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: artist_annotation
CREATE TABLE artist_annotation (-- replicate (verbose)
artist INTEGER NOT NULL,-- PK, references artist.id
annotation INTEGER NOT NULL-- PK, references annotation.id
);
-- Table: artist_attribute
CREATE TABLE artist_attribute (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
artist INTEGER NOT NULL,-- references artist.id
artist_attribute_type INTEGER NOT NULL,-- references artist_attribute_type.id
artist_attribute_type_allowed_value INTEGER,-- references artist_attribute_type_allowed_value.id
artist_attribute_text TEXT CHECK ( (artist_attribute_type_allowed_value IS NULL AND
artist_attribute_text IS NOT NULL) OR
(artist_attribute_type_allowed_value IS NOT NULL AND
artist_attribute_text IS NULL) )
);
-- Table: artist_attribute_type
CREATE TABLE artist_attribute_type (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
name VARCHAR (255) NOT NULL,
comment VARCHAR (255) NOT NULL
DEFAULT '',
free_text BOOLEAN NOT NULL,
parent INTEGER,-- references artist_attribute_type.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: artist_attribute_type_allowed_value
CREATE TABLE artist_attribute_type_allowed_value (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
artist_attribute_type INTEGER NOT NULL,-- references artist_attribute_type.id
value TEXT,
parent INTEGER,-- references artist_attribute_type_allowed_value.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: artist_credit
CREATE TABLE artist_credit (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR NOT NULL,
artist_count INTEGER NOT NULL,
ref_count INTEGER DEFAULT 0,
created TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: artist_credit_name
CREATE TABLE artist_credit_name (-- replicate (verbose)
artist_credit INTEGER NOT NULL,-- PK, references artist_credit.id CASCADE
position INTEGER NOT NULL,-- PK
artist INTEGER NOT NULL,-- references artist.id CASCADE
name VARCHAR NOT NULL,
join_phrase TEXT NOT NULL
DEFAULT ''
);
-- Table: artist_gid_redirect
CREATE TABLE artist_gid_redirect (-- replicate (verbose)
gid TEXT NOT NULL,-- PK
new_id INTEGER NOT NULL,-- references artist.id
created TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: artist_ipi
CREATE TABLE artist_ipi (-- replicate (verbose)
artist INTEGER NOT NULL,-- PK, references artist.id
ipi CHAR (11) NOT NULL,-- PK CHECK (ipi ~ E'^\\d{11}$')
edits_pending INTEGER NOT NULL
DEFAULT 0
CHECK (edits_pending >= 0),
created TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: artist_isni
CREATE TABLE artist_isni (-- replicate (verbose)
artist INTEGER NOT NULL,-- PK, references artist.id
isni CHAR (16) NOT NULL,-- PK CHECK (isni ~ E'^\\d{15}[\\dX]$')
edits_pending INTEGER NOT NULL
DEFAULT 0
CHECK (edits_pending >= 0),
created TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: artist_meta
CREATE TABLE artist_meta (-- replicate
id INTEGER NOT NULL,-- PK, references artist.id CASCADE
rating INTEGER CHECK (rating >= 0 AND
rating <= 100),
rating_count INTEGER
);
-- Table: artist_rating_raw
CREATE TABLE artist_rating_raw (
artist INTEGER NOT NULL,-- PK, references artist.id
editor INTEGER NOT NULL,-- PK, references editor.id
rating INTEGER NOT NULL
CHECK (rating >= 0 AND
rating <= 100)
);
-- Table: artist_tag
CREATE TABLE artist_tag (-- replicate (verbose)
artist INTEGER NOT NULL,-- PK, references artist.id
tag INTEGER NOT NULL,-- PK, references tag.id
count INTEGER NOT NULL,
last_updated TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: artist_tag_raw
CREATE TABLE artist_tag_raw (
artist INTEGER NOT NULL,-- PK, references artist.id
editor INTEGER NOT NULL,-- PK, references editor.id
tag INTEGER NOT NULL,-- PK, references tag.id
is_upvote BOOLEAN NOT NULL
DEFAULT TRUE
);
-- Table: artist_type
CREATE TABLE artist_type (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR (255) NOT NULL,
parent INTEGER,-- references artist_type.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: autoeditor_election
CREATE TABLE autoeditor_election (
id INTEGER PRIMARY KEY AUTOINCREMENT,
candidate INTEGER NOT NULL,-- references editor.id
proposer INTEGER NOT NULL,-- references editor.id
seconder_1 INTEGER,-- references editor.id
seconder_2 INTEGER,-- references editor.id
status INTEGER NOT NULL
DEFAULT 1
CHECK (status IN (1, 2, 3, 4, 5, 6) ),-- 1 : has proposer
/* 2 : has seconder_1 */yes_votes INTEGER NOT NULL
DEFAULT 0,
no_votes INTEGER NOT NULL
DEFAULT 0,
propose_time TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
open_time TEXT,
close_time TEXT
);
-- 3 : has seconder_2 (voting open)-- 4 : accepted!-- 5 : rejected-- 6 : cancelled (by proposer)
-- Table: autoeditor_election_vote
CREATE TABLE autoeditor_election_vote (
id INTEGER PRIMARY KEY AUTOINCREMENT,
autoeditor_election INTEGER NOT NULL,-- references autoeditor_election.id
voter INTEGER NOT NULL,-- references editor.id
vote INTEGER NOT NULL
CHECK (vote IN ( -1, 0, 1) ),
vote_time TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
NOT NULL
);
-- Table: cdtoc
CREATE TABLE cdtoc (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,
discid CHAR (28) NOT NULL,
freedb_id CHAR (8) NOT NULL,
track_count INTEGER NOT NULL,
leadout_offset INTEGER NOT NULL,
track_offset "INTEGER []" NOT NULL,
degraded BOOLEAN NOT NULL
DEFAULT FALSE,
created TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: cdtoc_raw
CREATE TABLE cdtoc_raw (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,-- PK
[release] INTEGER NOT NULL,-- references release_raw.id
discid CHAR (28) NOT NULL,
track_count INTEGER NOT NULL,
leadout_offset INTEGER NOT NULL,
track_offset "INTEGER []" NOT NULL
);
-- Table: country_area
CREATE TABLE country_area (-- replicate (verbose)
area INTEGER-- PK, references area.id
);
-- Table: deleted_entity
CREATE TABLE deleted_entity (
gid TEXT NOT NULL,-- PK
data JSONB NOT NULL,
deleted_at TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: edit
CREATE TABLE edit (
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id
type INTEGER NOT NULL,
status INTEGER NOT NULL,
autoedit INTEGER NOT NULL
DEFAULT 0,
open_time TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
close_time TEXT,
expire_time TEXT NOT NULL,
language INTEGER,-- references language.id
quality INTEGER NOT NULL
DEFAULT 1
);
-- Table: edit_area
CREATE TABLE edit_area (
edit INTEGER NOT NULL,-- PK, references edit.id
area INTEGER NOT NULL-- PK, references area.id CASCADE
);
-- Table: edit_artist
CREATE TABLE edit_artist (
edit INTEGER NOT NULL,-- PK, references edit.id
artist INTEGER NOT NULL,-- PK, references artist.id CASCADE
status INTEGER NOT NULL-- materialized from edit.status
);
-- Table: edit_data
CREATE TABLE edit_data (
edit INTEGER NOT NULL,-- PK, references edit.id
data JSONB NOT NULL
);
-- Table: edit_event
CREATE TABLE edit_event (
edit INTEGER NOT NULL,-- PK, references edit.id
event INTEGER NOT NULL-- PK, references event.id CASCADE
);
-- Table: edit_instrument
CREATE TABLE edit_instrument (
edit INTEGER NOT NULL,-- PK, references edit.id
instrument INTEGER NOT NULL-- PK, references instrument.id CASCADE
);
-- Table: edit_label
CREATE TABLE edit_label (
edit INTEGER NOT NULL,-- PK, references edit.id
label INTEGER NOT NULL,-- PK, references label.id CASCADE
status INTEGER NOT NULL-- materialized from edit.status
);
-- Table: edit_note
CREATE TABLE edit_note (
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id
edit INTEGER NOT NULL,-- references edit.id
text TEXT NOT NULL,
post_time TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
);
-- Table: edit_note_recipient
CREATE TABLE edit_note_recipient (
recipient INTEGER NOT NULL,-- PK, references editor.id
edit_note INTEGER NOT NULL-- PK, references edit_note.id
);
-- Table: edit_place
CREATE TABLE edit_place (
edit INTEGER NOT NULL,-- PK, references edit.id
place INTEGER NOT NULL-- PK, references place.id CASCADE
);
-- Table: edit_recording
CREATE TABLE edit_recording (
edit INTEGER NOT NULL,-- PK, references edit.id
recording INTEGER NOT NULL-- PK, references recording.id CASCADE
);
-- Table: edit_release
CREATE TABLE edit_release (
edit INTEGER NOT NULL,-- PK, references edit.id
[release] INTEGER NOT NULL-- PK, references release.id CASCADE
);
-- Table: edit_release_group
CREATE TABLE edit_release_group (
edit INTEGER NOT NULL,-- PK, references edit.id
release_group INTEGER NOT NULL-- PK, references release_group.id CASCADE
);
-- Table: edit_series
CREATE TABLE edit_series (
edit INTEGER NOT NULL,-- PK, references edit.id
series INTEGER NOT NULL-- PK, references series.id CASCADE
);
-- Table: edit_url
CREATE TABLE edit_url (
edit INTEGER NOT NULL,-- PK, references edit.id
url INTEGER NOT NULL-- PK, references url.id CASCADE
);
-- Table: edit_work
CREATE TABLE edit_work (
edit INTEGER NOT NULL,-- PK, references edit.id
work INTEGER NOT NULL-- PK, references work.id CASCADE
);
-- Table: editor
CREATE TABLE editor (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR (64) NOT NULL,
privs INTEGER DEFAULT 0,
email VARCHAR (64) DEFAULT NULL,
website VARCHAR (255) DEFAULT NULL,
bio TEXT DEFAULT NULL,
member_since TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
email_confirm_date TEXT,
last_login_date TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
last_updated TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
birth_date DATE,
gender INTEGER,-- references gender.id
area INTEGER,-- references area.id
password VARCHAR (128) NOT NULL,
ha1 CHAR (32) NOT NULL,
deleted BOOLEAN NOT NULL
DEFAULT FALSE
);
-- Table: editor_collection
CREATE TABLE editor_collection (
id INTEGER PRIMARY KEY AUTOINCREMENT,
gid TEXT NOT NULL,
editor INTEGER NOT NULL,-- references editor.id
name VARCHAR NOT NULL,
public BOOLEAN NOT NULL
DEFAULT FALSE,
description TEXT DEFAULT ''
NOT NULL,
type INTEGER NOT NULL-- references editor_collection_type.id
);
-- Table: editor_collection_area
CREATE TABLE editor_collection_area (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
area INTEGER NOT NULL-- PK, references area.id
);
-- Table: editor_collection_artist
CREATE TABLE editor_collection_artist (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
artist INTEGER NOT NULL-- PK, references artist.id
);
-- Table: editor_collection_deleted_entity
CREATE TABLE editor_collection_deleted_entity (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
gid TEXT NOT NULL-- PK, references deleted_entity.gid
);
-- Table: editor_collection_event
CREATE TABLE editor_collection_event (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
event INTEGER NOT NULL-- PK, references event.id
);
-- Table: editor_collection_instrument
CREATE TABLE editor_collection_instrument (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
instrument INTEGER NOT NULL-- PK, references instrument.id
);
-- Table: editor_collection_label
CREATE TABLE editor_collection_label (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
label INTEGER NOT NULL-- PK, references label.id
);
-- Table: editor_collection_place
CREATE TABLE editor_collection_place (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
place INTEGER NOT NULL-- PK, references place.id
);
-- Table: editor_collection_recording
CREATE TABLE editor_collection_recording (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
recording INTEGER NOT NULL-- PK, references recording.id
);
-- Table: editor_collection_release
CREATE TABLE editor_collection_release (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
[release] INTEGER NOT NULL-- PK, references release.id
);
-- Table: editor_collection_release_group
CREATE TABLE editor_collection_release_group (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
release_group INTEGER NOT NULL-- PK, references release_group.id
);
-- Table: editor_collection_series
CREATE TABLE editor_collection_series (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
series INTEGER NOT NULL-- PK, references series.id
);
-- Table: editor_collection_type
CREATE TABLE editor_collection_type (-- replicate
id INTEGER PRIMARY KEY AUTOINCREMENT,
name VARCHAR (255) NOT NULL,
entity_type VARCHAR (50) NOT NULL,
parent INTEGER,-- references editor_collection_type.id
child_order INTEGER NOT NULL
DEFAULT 0,
description TEXT,
gid TEXT NOT NULL
);
-- Table: editor_collection_work
CREATE TABLE editor_collection_work (
collection INTEGER NOT NULL,-- PK, references editor_collection.id
work INTEGER NOT NULL-- PK, references work.id
);
-- Table: editor_language
CREATE TABLE editor_language (
editor INTEGER NOT NULL,-- PK, references editor.id
language INTEGER NOT NULL,-- PK, references language.id
fluency INTEGER NOT NULL
CHECK (fluency IN ('basic', 'intermediate', 'advanced', 'native') )
);
-- Table: editor_oauth_token
CREATE TABLE editor_oauth_token (
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id
application INTEGER NOT NULL,-- references application.id
authorization_code TEXT,
refresh_token TEXT,
access_token TEXT,
expire_time TEXT NOT NULL,
scope INTEGER NOT NULL
DEFAULT 0,
granted TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
NOT NULL
);
-- Table: editor_preference
CREATE TABLE editor_preference (
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id
name VARCHAR (50) NOT NULL,
value VARCHAR (100) NOT NULL
);
-- Table: editor_subscribe_artist
CREATE TABLE editor_subscribe_artist (
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id
artist INTEGER NOT NULL,-- references artist.id
last_edit_sent INTEGER NOT NULL-- references edit.id
);
-- Table: editor_subscribe_artist_deleted
CREATE TABLE editor_subscribe_artist_deleted (
editor INTEGER NOT NULL,-- PK, references editor.id
gid TEXT NOT NULL,-- PK, references deleted_entity.gid
deleted_by INTEGER NOT NULL-- references edit.id
);
-- Table: editor_subscribe_collection
CREATE TABLE editor_subscribe_collection (
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id
collection INTEGER NOT NULL,-- weakly references editor_collection.id
last_edit_sent INTEGER NOT NULL,-- weakly references edit.id
available BOOLEAN NOT NULL
DEFAULT TRUE,
last_seen_name VARCHAR (255)
);
-- Table: editor_subscribe_editor
CREATE TABLE editor_subscribe_editor (
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id (the one who has subscribed)
subscribed_editor INTEGER NOT NULL,-- references editor.id (the one being subscribed)
last_edit_sent INTEGER NOT NULL-- weakly references edit.id
);
-- Table: editor_subscribe_label
CREATE TABLE editor_subscribe_label (
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id
label INTEGER NOT NULL,-- references label.id
last_edit_sent INTEGER NOT NULL-- references edit.id
);
-- Table: editor_subscribe_label_deleted
CREATE TABLE editor_subscribe_label_deleted (
editor INTEGER NOT NULL,-- PK, references editor.id
gid TEXT NOT NULL,-- PK, references deleted_entity.gid
deleted_by INTEGER NOT NULL-- references edit.id
);
-- Table: editor_subscribe_series
CREATE TABLE editor_subscribe_series (
id INTEGER PRIMARY KEY AUTOINCREMENT,
editor INTEGER NOT NULL,-- references editor.id
series INTEGER NOT NULL,-- references series.id
last_edit_sent INTEGER NOT NULL-- references edit.id
);
-- Table: editor_subscribe_series_deleted
CREATE TABLE editor_subscribe_series_deleted (
editor INTEGER NOT NULL,-- PK, references editor.id
gid TEXT NOT NULL,-- PK, references deleted_entity.gid
deleted_by INTEGER NOT NULL-- references edit.id
);
-- Table: editor_watch_artist
CREATE TABLE editor_watch_artist (
artist INTEGER NOT NULL,-- PK, references artist.id CASCADE
editor INTEGER NOT NULL-- PK, references editor.id CASCADE
);
-- Table: editor_watch_preferences
CREATE TABLE editor_watch_preferences (
editor INTEGER NOT NULL,-- PK, references editor.id CASCADE
notify_via_email BOOLEAN NOT NULL
DEFAULT TRUE,
notification_timeframe INTERVAL NOT NULL
DEFAULT '1 week',
last_checked TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') )
NOT NULL
);
-- Table: editor_watch_release_group_type
CREATE TABLE editor_watch_release_group_type (
editor INTEGER NOT NULL,-- PK, references editor.id CASCADE
release_group_type INTEGER NOT NULL-- PK, references release_group_primary_type.id
);
-- Table: editor_watch_release_status
CREATE TABLE editor_watch_release_status (
editor INTEGER NOT NULL,-- PK, references editor.id CASCADE
release_status INTEGER NOT NULL-- PK, references release_status.id
);
-- Table: event
CREATE TABLE event (-- replicate (verbose)
id INTEGER PRIMARY KEY AUTOINCREMENT,
gid TEXT NOT NULL,
name VARCHAR NOT NULL,
begin_date_year INTEGER,
begin_date_month INTEGER,
begin_date_day INTEGER,
end_date_year INTEGER,
end_date_month INTEGER,
end_date_day INTEGER,
time [TIME WITHOUT TIME ZONE],
type INTEGER,
cancelled BOOLEAN NOT/* references event_type.id */ NULL
DEFAULT FALSE,
setlist TEXT,
comment VARCHAR (255) NOT NULL
DEFAULT '',
edits_pending INTEGER NOT NULL
DEFAULT 0
CHECK (edits_pending >= 0),
last_updated TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%f+00', 'now') ),
ended BOOLEAN NOT NULL
DEFAULT FALSE
CONSTRAINT event_ended_check CHECK ( ( (end_date_year IS/* If any end date fields are not null, then ended must be true */ NOT NULL OR
end_date_month IS NOT NULL OR
end_date_day IS NOT NULL) AND
ended = TRUE) OR
( (end_date_year IS/* Otherwise, all end date fields must be null */ NULL AND
end_date_month IS NULL AND
end_date_day IS NULL) ) )
);
-- Table: event_alias