-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathbase.sql
7136 lines (5366 loc) · 228 KB
/
base.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 SCHEMA bapsplanner;
COMMENT ON SCHEMA bapsplanner IS 'Used by Show Planner.';
CREATE SCHEMA jukebox;
COMMENT ON SCHEMA jukebox IS 'Used by jukebox auto-music-player.';
CREATE SCHEMA mail;
COMMENT ON SCHEMA mail IS 'Mailing lists.';
CREATE SCHEMA metadata;
COMMENT ON SCHEMA metadata IS 'Metadata systems.';
CREATE SCHEMA music;
COMMENT ON SCHEMA music IS 'Charts and possibly other stuff too.';
CREATE SCHEMA myury;
COMMENT ON SCHEMA myury IS 'Schema for new/migrated data for the Members Internal replacement';
CREATE SCHEMA people;
COMMENT ON SCHEMA people IS 'Tables for the LeRouge Extensible Roles (Or User Groups).';
CREATE SCHEMA schedule;
COMMENT ON SCHEMA schedule IS 'Schema for the MyRadio schedule.';
CREATE SCHEMA sis2;
COMMENT ON SCHEMA sis2 IS 'Used by Studio Infomation Service.';
CREATE SCHEMA tracklist;
COMMENT ON SCHEMA tracklist IS 'Provides a schema that logs played out tracks for PPL track returns';
CREATE SCHEMA uryplayer;
COMMENT ON SCHEMA uryplayer IS 'URY Player';
CREATE SCHEMA webcam;
CREATE SCHEMA website;
COMMENT ON SCHEMA website IS 'Collection of data relating to the operation of the public-facing website.';
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
CREATE FUNCTION bapstotracklist() RETURNS TRIGGER AS $$
DECLARE
audid INTEGER;
BEGIN
IF ((TG_OP = 'UPDATE')
AND ((SELECT COUNT(*) FROM (SELECT sel.action FROM selector sel
WHERE sel.action >= 4 AND sel.action <= 11
ORDER BY sel.TIME DESC LIMIT 1) AS seltop
INNER JOIN tracklist.selbaps bsel ON (seltop.action = bsel.selaction)
WHERE bsel.bapsloc = NEW."serverid" AND (NEW."timeplayed" >= (SELECT sel.TIME FROM selector sel
ORDER BY sel.TIME DESC
LIMIT 1))) = 1)
AND ((SELECT COUNT(*) FROM baps_audio ba WHERE ba.audioid = NEW."audioid" AND ba.trackid > 0) = 1)
AND ((NEW."timestopped" - NEW."timeplayed" > '00:00:30'))
AND ((SELECT COUNT(*) FROM tracklist.tracklist WHERE bapsaudioid = NEW."audiologid") = 0))
THEN
INSERT INTO tracklist.tracklist (SOURCE, timestart, timestop, timeslotid, bapsaudioid)
VALUES ('b', NEW."timeplayed", NEW."timestopped", (SELECT show_season_timeslot_id FROM schedule.show_season_timeslot
WHERE start_time <= NOW()
AND (start_time + duration) >= NOW()
AND show_season_id != 0
ORDER BY show_season_timeslot_id ASC
LIMIT 1),
NEW."audiologid")
RETURNING audiologid INTO audid;
INSERT INTO tracklist.track_rec
VALUES ("audid", (SELECT rec.recordid FROM rec_track rec
INNER JOIN baps_audio ba USING (trackid)
WHERE ba.audioid = NEW."audioid"),
(SELECT trackid FROM baps_audio WHERE audioid = NEW."audioid"));
END IF;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION clear_item_func() RETURNS trigger AS $$
BEGIN
IF OLD.textitemid IS NOT NULL
THEN
DELETE FROM baps_textitem WHERE textitemid = OLD.textitemid;
END IF;
IF OLD.libraryitemid IS NOT NULL
THEN
DELETE FROM baps_libraryitem WHERE libraryitemid = OLD.libraryitemid;
END IF;
IF OLD.fileitemid IS NOT NULL
THEN
DELETE FROM baps_fileitem WHERE fileitemid = OLD.fileitemid;
END IF;
RETURN OLD;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION process_gammu_text() RETURNS trigger AS $$
BEGIN
IF (TG_OP = 'INSERT')
THEN
IF ((SELECT show_season_timeslot_id FROM schedule.show_season_timeslot
WHERE start_time <= NOW() AND (start_time + duration) >= NOW()
ORDER BY show_season_timeslot_id ASC
LIMIT 1) IS NOT NULL)
THEN
INSERT INTO sis2.messages (commtypeid, timeslotid, sender, subject, content, statusid)
VALUES (2, (SELECT show_season_timeslot_id FROM schedule.show_season_timeslot
WHERE start_time <= NOW() AND (start_time + duration) >= NOW()
ORDER BY show_season_timeslot_id ASC
LIMIT 1),
NEW."SenderNumber", NEW."TextDecoded", NEW."TextDecoded", 1);
RETURN NEW;
ELSE
INSERT INTO sis2.messages (commtypeid, timeslotid, sender, subject, content, statusid)
VALUES (2, 118540, NEW."SenderNumber", NEW."TextDecoded", NEW."TextDecoded", 1);
RETURN NEW;
END IF;
END IF;
RETURN NULL;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION set_shelfcode_func() RETURNS trigger AS $$
DECLARE
myshelfnumber integer DEFAULT 0;
recordrow RECORD;
BEGIN
IF ((NEW.media = '7' OR NEW.media = '2') AND NEW.format = 'a')
THEN
FOR recordrow IN (SELECT * FROM rec_record
WHERE media = NEW.media AND (format = '7' OR format = '2') AND shelfletter = NEW.shelfletter
ORDER BY shelfnumber)
LOOP
IF (recordrow.shelfnumber > myshelfnumber + 1)
THEN
EXIT;
END IF;
myshelfnumber = myshelfnumber + 1;
END LOOP;
ELSE
FOR recordrow IN (SELECT * FROM rec_record
WHERE media = NEW.media AND format = NEW.format AND shelfletter = NEW.shelfletter
ORDER BY shelfnumber)
LOOP
IF (recordrow.shelfnumber > myshelfnumber + 1)
THEN
EXIT;
END IF;
myshelfnumber = myshelfnumber + 1;
END LOOP;
END IF;
NEW.shelfnumber = myshelfnumber + 1;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION update_timestamp() RETURNS trigger AS $$
BEGIN
NEW."UpdatedInDB" := LOCALTIMESTAMP(0);
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE SEQUENCE bapsplanner.auto_playlists_autoplaylistid_seq
START WITH 3
INCREMENT BY 1
MINVALUE 3
NO MAXVALUE
CACHE 1;
CREATE TABLE bapsplanner.auto_playlists (
auto_playlist_id integer DEFAULT nextval('bapsplanner.auto_playlists_autoplaylistid_seq'::regclass) NOT NULL,
name character varying(30) NOT NULL,
query text
);
CREATE SEQUENCE bapsplanner.client_ids_client_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE TABLE bapsplanner.client_ids (
client_id integer DEFAULT nextval('bapsplanner.client_ids_client_id_seq'::regclass) NOT NULL,
show_season_timeslot_id integer,
session_id character varying(64)
);
CREATE SEQUENCE bapsplanner.managed_items_manageditemid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE TABLE bapsplanner.managed_items (
manageditemid integer DEFAULT nextval('bapsplanner.managed_items_manageditemid_seq'::regclass) NOT NULL,
managedplaylistid integer NOT NULL,
title character varying NOT NULL,
length time without time zone,
bpm smallint,
expirydate date,
memberid integer
);
CREATE SEQUENCE bapsplanner.managed_items_managedplaylistid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE bapsplanner.managed_items_managedplaylistid_seq OWNED BY bapsplanner.managed_items.managedplaylistid;
CREATE TABLE bapsplanner.managed_playlists (
managedplaylistid integer NOT NULL,
name character varying,
folder character varying,
item_ttl integer
);
COMMENT ON COLUMN bapsplanner.managed_playlists.item_ttl IS 'The default period of time an item in this playlist will live for, in seconds. A value of NULL will not expire.';
CREATE SEQUENCE bapsplanner.managed_playlists_managedplaylistid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE bapsplanner.managed_playlists_managedplaylistid_seq OWNED BY bapsplanner.managed_playlists.managedplaylistid;
CREATE TABLE bapsplanner.managed_user_items (
manageditemid integer DEFAULT nextval('bapsplanner.managed_items_manageditemid_seq'::regclass) NOT NULL,
managedplaylistid character varying(35) NOT NULL,
title character varying NOT NULL,
length time without time zone,
bpm smallint
);
CREATE TABLE bapsplanner.secure_play_token (
sessionid character varying(32) NOT NULL,
memberid integer NOT NULL,
"timestamp" timestamp without time zone DEFAULT now() NOT NULL,
trackid integer NOT NULL
);
COMMENT ON TABLE bapsplanner.secure_play_token IS 'Stores ''tokens'' that allow a user to play a file - once the file is played the token is removed preventing downloads or sharing.';
CREATE TABLE bapsplanner.timeslot_items (
timeslot_item_id integer NOT NULL,
timeslot_id integer NOT NULL,
channel_id smallint NOT NULL,
weight integer NOT NULL,
cue integer NOT NULL DEFAULT 0,
rec_track_id integer,
managed_item_id integer,
user_item_id integer,
legacy_aux_id integer
);
CREATE SEQUENCE bapsplanner.timeslot_items_timeslot_item_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE bapsplanner.timeslot_items_timeslot_item_id_seq OWNED BY bapsplanner.timeslot_items.timeslot_item_id;
SET search_path = jukebox, pg_catalog;
CREATE SEQUENCE playlist_availability_playlist_availability_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE TABLE playlist_availability (
memberid integer,
approvedid integer,
effective_from timestamp with time zone NOT NULL,
effective_to timestamp with time zone,
playlist_availability_id integer DEFAULT nextval('jukebox.playlist_availability_playlist_availability_id_seq'::regclass) NOT NULL,
weight integer NOT NULL,
playlistid character varying NOT NULL
);
ALTER SEQUENCE playlist_availability_playlist_availability_id_seq OWNED BY playlist_availability.playlist_availability_id;
CREATE TABLE playlist_entries (
playlistid character varying(15) NOT NULL,
trackid integer NOT NULL,
revision_added integer NOT NULL,
revision_removed integer,
entryid integer NOT NULL
);
CREATE SEQUENCE playlist_entries_entryid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE playlist_entries_entryid_seq OWNED BY playlist_entries.entryid;
CREATE TABLE playlist_revisions (
playlistid character varying(15) NOT NULL,
revisionid integer NOT NULL,
"timestamp" timestamp without time zone DEFAULT now() NOT NULL,
author integer NOT NULL,
notes text
);
CREATE SEQUENCE playlist_timeslot_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE TABLE playlist_timeslot (
id integer DEFAULT nextval('playlist_timeslot_id_seq'::regclass) NOT NULL,
memberid integer NOT NULL,
approvedid integer,
day smallint NOT NULL,
start_time time without time zone NOT NULL,
end_time time without time zone NOT NULL,
playlist_availability_id integer NOT NULL
);
COMMENT ON COLUMN playlist_timeslot.day IS '1-7 (1=Monday)';
CREATE TABLE playlists (
playlistid character varying(15) NOT NULL,
title character varying(50) NOT NULL,
image character varying(50) DEFAULT 'music_note.png'::character varying,
description character varying(250),
lock integer,
locktime integer,
weight integer DEFAULT 0 NOT NULL,
exported boolean DEFAULT true NOT NULL,
weightx integer DEFAULT 0 NOT NULL
);
COMMENT ON COLUMN playlists.weight IS 'Relative to the other playlists, how often should a track from this be played on the jukebox? If 0, never play it.';
COMMENT ON COLUMN playlists.weightx IS 'Weightings for post-watershed jukebox.';
CREATE TABLE request (
request_id integer NOT NULL,
memberid integer NOT NULL,
date timestamp with time zone NOT NULL,
queue character varying NOT NULL,
trackid integer NOT NULL
);
CREATE SEQUENCE request_request_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE request_request_id_seq OWNED BY request.request_id;
CREATE TABLE silence_log (
silenceid integer NOT NULL,
starttime timestamp without time zone DEFAULT now() NOT NULL,
stoptime timestamp without time zone,
handledby integer
);
COMMENT ON TABLE silence_log IS 'Stores a log of silence events';
CREATE VIEW silence AS
SELECT silence_log.starttime FROM silence_log WHERE (silence_log.stoptime = NULL::timestamp without time zone) ORDER BY silence_log.silenceid LIMIT 1;
COMMENT ON VIEW silence IS 'Gets start time of a current silence event. Should check if time is > 1 second';
CREATE SEQUENCE silence_log_silenceid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE silence_log_silenceid_seq OWNED BY silence_log.silenceid;
CREATE TABLE track_blacklist (
trackid integer NOT NULL
);
COMMENT ON TABLE track_blacklist IS 'A list of Tracks that should, under no circumstances, be played on the jukebox.';
SET search_path = mail, pg_catalog;
CREATE TABLE alias (
alias_id integer NOT NULL,
source character varying NOT NULL
);
CREATE SEQUENCE alias_alias_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE alias_alias_id_seq OWNED BY alias.alias_id;
CREATE TABLE alias_list (
alias_id integer NOT NULL,
destination integer NOT NULL
);
CREATE TABLE alias_member (
alias_id integer NOT NULL,
destination integer NOT NULL
);
CREATE TABLE alias_officer (
alias_id integer NOT NULL,
destination integer NOT NULL
);
CREATE SEQUENCE alias_source_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE TABLE alias_text (
alias_id integer NOT NULL,
destination character varying NOT NULL
);
CREATE TABLE email (
email_id integer NOT NULL,
sender integer,
subject text NOT NULL,
body text NOT NULL,
"timestamp" timestamp without time zone DEFAULT now()
);
CREATE TABLE email_recipient_list (
email_id integer NOT NULL,
listid integer NOT NULL,
sent boolean DEFAULT false NOT NULL
);
CREATE TABLE email_recipient_member (
email_id integer NOT NULL,
memberid integer NOT NULL,
sent boolean DEFAULT false NOT NULL
);
CREATE SEQUENCE emails_email_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE emails_email_id_seq OWNED BY email.email_id;
SET search_path = metadata, pg_catalog;
CREATE TABLE metadata_key (
metadata_key_id integer NOT NULL,
name character varying NOT NULL,
allow_multiple boolean DEFAULT false,
description text DEFAULT ''::text NOT NULL,
cache_duration integer DEFAULT 300 NOT NULL,
plural character varying(255),
searchable boolean DEFAULT false NOT NULL
);
COMMENT ON TABLE metadata_key IS 'Stores possible types of textual metadatum. Used by all three _metadata tables';
COMMENT ON COLUMN metadata_key.metadata_key_id IS 'A unique identifier for each metadata type';
COMMENT ON COLUMN metadata_key.name IS 'A human-readable name for the metadata key';
COMMENT ON COLUMN metadata_key.description IS 'A short description of the semantics/meaning of this key, and where it is applicable.';
CREATE SEQUENCE metadata_key_metadata_key_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE metadata_key_metadata_key_id_seq OWNED BY metadata_key.metadata_key_id;
CREATE TABLE package (
name character varying(50) NOT NULL,
description text NOT NULL,
package_id integer NOT NULL,
weight integer
);
CREATE TABLE package_image_metadata (
memberid integer,
approvedid integer,
effective_from timestamp with time zone,
effective_to timestamp with time zone,
metadata_key_id integer NOT NULL,
metadata_value character varying(100) NOT NULL,
element_id integer NOT NULL,
package_image_metadata_id integer NOT NULL,
package_id integer
);
CREATE SEQUENCE package_image_metadata_package_image_metadata_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE package_image_metadata_package_image_metadata_id_seq OWNED BY package_image_metadata.package_image_metadata_id;
CREATE SEQUENCE package_package_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE package_package_id_seq OWNED BY package.package_id;
CREATE TABLE package_text_metadata (
memberid integer,
approvedid integer,
effective_from timestamp with time zone,
effective_to timestamp with time zone,
metadata_key_id integer NOT NULL,
metadata_value text NOT NULL,
element_id integer NOT NULL,
package_text_metadata_id integer NOT NULL,
package_id integer
);
CREATE SEQUENCE package_text_metadata_package_text_metadata_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE package_text_metadata_package_text_metadata_id_seq OWNED BY package_text_metadata.package_text_metadata_id;
SET search_path = music, pg_catalog;
CREATE TABLE chart_release (
submitted timestamp with time zone,
chart_release_id integer NOT NULL,
chart_type_id integer NOT NULL
);
CREATE SEQUENCE chart_release_chart_release_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE chart_release_chart_release_id_seq OWNED BY chart_release.chart_release_id;
CREATE TABLE chart_row (
chart_row_id integer NOT NULL,
chart_release_id integer NOT NULL,
"position" smallint NOT NULL,
track character varying(255),
artist character varying(255),
trackid integer,
CONSTRAINT chart_row_position_check CHECK (("position" >= 0))
);
CREATE SEQUENCE chart_row_chart_row_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE chart_row_chart_row_id_seq OWNED BY chart_row.chart_row_id;
CREATE TABLE chart_type (
name character varying(50) NOT NULL,
description text NOT NULL,
chart_type_id integer NOT NULL
);
CREATE SEQUENCE chart_type_chart_type_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE chart_type_chart_type_id_seq OWNED BY chart_type.chart_type_id;
SET search_path = myury, pg_catalog;
CREATE TABLE act_permission (
actpermissionid integer NOT NULL,
serviceid integer NOT NULL,
moduleid integer,
actionid integer,
typeid integer
);
COMMENT ON TABLE act_permission IS 'Specifies what permissions are required in order to use a feature. This is an *OR* type permission system - any of these matching will grant access.
A NULL in the module or action field matches any module or action.
A NULL permissionid means that no permissions are required to use that Service/Module/Action combination.
NULL permissions on wildcards will be ignored.';
CREATE SEQUENCE act_permission_actpermissionid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE act_permission_actpermissionid_seq OWNED BY act_permission.actpermissionid;
CREATE TABLE actions (
actionid integer NOT NULL,
moduleid integer,
name character varying,
enabled boolean DEFAULT true NOT NULL,
custom_uri character varying
);
COMMENT ON TABLE actions IS 'Stores Actions within managed MyRadio Service Modules';
CREATE SEQUENCE actions_actionid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE actions_actionid_seq OWNED BY actions.actionid;
CREATE TABLE api_class_map (
api_map_id integer NOT NULL,
class_name character varying NOT NULL,
api_name character varying NOT NULL
);
COMMENT ON TABLE api_class_map IS 'Maps MyRadio Internal classes to the names exposed to the MyRadio API. For example, MyRadio_Track would map to Track. If a class is not mapped, it is not available at all to the API.';
CREATE SEQUENCE api_class_map_api_map_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE api_class_map_api_map_id_seq OWNED BY api_class_map.api_map_id;
CREATE TABLE api_key (
key_string character varying NOT NULL,
description character varying NOT NULL,
revoked boolean DEFAULT false NOT NULL
);
COMMENT ON TABLE api_key IS 'Access keys for the MyRadiopi';
INSERT INTO api_key (key_string, description) VALUES ('IUrnsb8AMkjqDRdfXvOMe3DqHLW8HJ1RNBPNJq3H1FQpiwQDs7Ufoxmsf5xZE9XEbQErRO97DG4xfyVAO7LuS2dOiVNZYoxkk4fEhDt8wR4sLXbghidtM5rLHcgkzO10', 'Swagger Documentation Key');
CREATE TABLE api_key_auth (
key_string character varying NOT NULL,
typeid integer NOT NULL
);
COMMENT ON TABLE api_key_auth IS 'Stores what API capabilities each key has.';
CREATE TABLE api_method_auth (
api_method_auth_id integer NOT NULL,
class_name character varying NOT NULL,
method_name character varying,
typeid integer
);
COMMENT ON TABLE api_method_auth IS 'Assigns permissions to API calls. If a Class or Object Method does not have a permission here, it is accessible only to Keys with "AUTH_APISUDO".
Other than the above exception, the permissions structure is identical to the standard myury action permission system.';
CREATE SEQUENCE api_method_auth_api_method_auth_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE api_method_auth_api_method_auth_id_seq OWNED BY api_method_auth.api_method_auth_id;
CREATE TABLE award_categories (
awardid integer NOT NULL,
name character varying NOT NULL
);
CREATE SEQUENCE award_categories_awardid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE award_categories_awardid_seq OWNED BY award_categories.awardid;
CREATE TABLE award_member (
awardmemberid integer NOT NULL,
awardid integer NOT NULL,
memberid integer NOT NULL,
awarded timestamp without time zone DEFAULT now() NOT NULL,
awardedby integer NOT NULL
);
CREATE SEQUENCE award_member_awardmemberid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE award_member_awardmemberid_seq OWNED BY award_member.awardmemberid;
CREATE TABLE modules (
moduleid integer NOT NULL,
serviceid integer,
name character varying,
enabled boolean DEFAULT true NOT NULL
);
COMMENT ON TABLE modules IS 'Stores Modules within MyRadio managed Services';
CREATE SEQUENCE modules_moduleid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE modules_moduleid_seq OWNED BY modules.moduleid;
CREATE TABLE password_reset_token (
token character varying NOT NULL,
expires timestamp without time zone NOT NULL,
used timestamp without time zone,
memberid integer NOT NULL
);
COMMENT ON TABLE password_reset_token IS 'Tokens used for sending password reset emails.';
CREATE TABLE photos (
photoid integer NOT NULL,
owner integer,
date_added timestamp without time zone DEFAULT now() NOT NULL,
format character varying DEFAULT 'png'::character varying NOT NULL
);
COMMENT ON COLUMN photos.format IS 'png, jpeg etc - should be the file extension.';
CREATE SEQUENCE photos_photoid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE photos_photoid_seq OWNED BY photos.photoid;
CREATE TABLE services (
serviceid integer NOT NULL,
name character varying,
enabled boolean DEFAULT true NOT NULL
);
COMMENT ON TABLE services IS 'Lists all Services managed by MyRadio';
CREATE SEQUENCE services_serviceid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE services_serviceid_seq OWNED BY services.serviceid;
CREATE TABLE services_versions (
serviceversionid integer NOT NULL,
serviceid integer NOT NULL,
version character varying NOT NULL,
path character varying NOT NULL,
is_default boolean DEFAULT false NOT NULL,
proxy_static boolean DEFAULT false
);
COMMENT ON COLUMN services_versions.proxy_static IS 'If true, Twig will be given a base url that proxies all static resources through a JS script to ensure the right version of the file is served.';
CREATE TABLE services_versions_member (
memberid integer NOT NULL,
serviceversionid integer NOT NULL
);
CREATE SEQUENCE services_versions_serviceversionid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE services_versions_serviceversionid_seq OWNED BY services_versions.serviceversionid;
CREATE TABLE api_key_log (
api_log_id integer NOT NULL,
key_string character varying NOT NULL,
"timestamp" timestamp without time zone DEFAULT now() NOT NULL,
remote_ip inet NOT NULL,
request_path character varying,
request_params json
);
COMMENT ON TABLE api_key_log IS 'Stores a record of API Requests by an API Key';
CREATE SEQUENCE api_key_log_api_log_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE api_key_log_api_log_id_seq OWNED BY api_key_log.api_log_id;
SET search_path = people, pg_catalog;
CREATE TABLE credit_type (
credit_type_id integer NOT NULL,
name character varying(255) NOT NULL,
plural character varying(255) NOT NULL,
is_in_byline boolean DEFAULT false NOT NULL
);
COMMENT ON TABLE credit_type IS 'Types of credit (associations between URY people and items such as shows or podcasts they have taken a role in creating).';
COMMENT ON COLUMN credit_type.plural IS 'A human-readable plural form of the show credit name, for example "presenters" or "producers".';
COMMENT ON COLUMN credit_type.is_in_byline IS 'If true, people credited with this credit type will appear in "with XYZ and ABC" by-lines for the show.';
CREATE TABLE group_root_role (
group_root_role_id integer NOT NULL,
role_id_id integer NOT NULL,
group_type_id integer NOT NULL,
group_leader_id integer
);
COMMENT ON COLUMN group_root_role.group_leader_id IS 'An optional reference to a role to be considered the ''leader'' role within the group defined by this root.';
CREATE SEQUENCE group_root_role_group_root_role_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE group_root_role_group_root_role_id_seq OWNED BY group_root_role.group_root_role_id;
CREATE TABLE group_type (
group_type_id integer NOT NULL,
name character varying(20) NOT NULL
);
CREATE SEQUENCE group_type_group_type_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE group_type_group_type_id_seq OWNED BY group_type.group_type_id;
CREATE TABLE metadata (
roleid integer NOT NULL,
key text NOT NULL,
value text NOT NULL
);
COMMENT ON TABLE metadata IS 'Key-value store for textual metadata associated with rules.
As of writing the metadata schema is:
''Collective-Name'' - human readable name for the group of everyone in this role, example ''Station Managers''. This is used as the team name when the role is a grouproot.
''Individual-Name'' - human readable name for an individual in this role, example ''Station Manager''.
''Acronym'' - self-explanatory, example ''SM''.
''Constitution-Section'' - section of the URY constitution defining the role, example: ''4.2.1''.
''Description'' - short description of the role, example: ''Manages the station''.';
COMMENT ON COLUMN metadata.roleid IS 'The unique ID of the role this metadatum concerns.';
COMMENT ON COLUMN metadata.key IS 'The key of the metadatum; should fit the site schema.';
COMMENT ON COLUMN metadata.value IS 'The value of the metadatum.';
CREATE TABLE role (
role_id integer NOT NULL,
alias character varying(100) NOT NULL,
visibilitylevel integer DEFAULT 1 NOT NULL,
isactive boolean DEFAULT true NOT NULL,
ordering integer DEFAULT 1 NOT NULL
);
COMMENT ON TABLE role IS 'Role definitions for LeRouge';
COMMENT ON COLUMN role.role_id IS 'The unique ID of this role.';
COMMENT ON COLUMN role.alias IS 'The internal alias name of this role. (Human readable name is considered metadata)';
COMMENT ON COLUMN role.visibilitylevel IS 'The visibility level of this role; see roles.visibilities.';
COMMENT ON COLUMN role.isactive IS 'If false, this role should be ignored completely during any role actions.';
COMMENT ON COLUMN role.ordering IS 'Coefficient used to determine how high up in lists this role appears (the lower, the more senior). For officer positions this should reflect the constitutional pecking order; for teams, it just defines the order of teams in any ordered team lists.';
CREATE TABLE role_inheritance (
child_id integer NOT NULL,
parent_id integer NOT NULL,
role_inheritance_id integer NOT NULL
);
COMMENT ON TABLE role_inheritance IS 'Pairs of roles and their immediate parents, used to create the role inheritance graph.';
COMMENT ON COLUMN role_inheritance.child_id IS 'The unique ID of the child row.';
COMMENT ON COLUMN role_inheritance.parent_id IS 'The unique ID of the parent row.';
COMMENT ON COLUMN role_inheritance.role_inheritance_id IS 'The unique ID of this inheritance binding.';
CREATE SEQUENCE role_inheritance_role_inheritance_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE role_inheritance_role_inheritance_id_seq OWNED BY role_inheritance.role_inheritance_id;
CREATE TABLE role_text_metadata (
metadata_key_id integer NOT NULL,
role_id integer NOT NULL,
metadata_value text,
effective_from timestamp with time zone,
memberid integer NOT NULL,
approvedid integer,
role_text_metadata_id integer NOT NULL,
effective_to timestamp with time zone
);
COMMENT ON COLUMN role_text_metadata.role_id IS 'The ID of the role this metadatum concerns.';
COMMENT ON COLUMN role_text_metadata.role_text_metadata_id IS 'The unique numeric ID of this metadatum.';
CREATE SEQUENCE role_metadata_role_metadata_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE role_metadata_role_metadata_id_seq OWNED BY role_text_metadata.role_text_metadata_id;
CREATE TABLE role_visibility (
role_visibility_id integer NOT NULL,
name character varying(100) NOT NULL,
description text
);
COMMENT ON TABLE role_visibility IS 'Enumeration of types of visibility and their human readable names and descriptions; used to ensure at the database level that incorrect visibilities cannot be used.';
COMMENT ON COLUMN role_visibility.role_visibility_id IS 'The unique ID of this visibility level.';
COMMENT ON COLUMN role_visibility.name IS 'A human-readable short name for the visibility level.';
COMMENT ON COLUMN role_visibility.description IS 'Optional description for the visibility level.';
CREATE SEQUENCE roles_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE roles_id_seq OWNED BY role.role_id;
CREATE SEQUENCE "schedule.showcredittype_id_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE "schedule.showcredittype_id_seq" OWNED BY credit_type.credit_type_id;
CREATE SEQUENCE types_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE types_id_seq OWNED BY role_visibility.role_visibility_id;
SET search_path = public, pg_catalog;
CREATE TABLE auth (
memberid integer NOT NULL,
lookupid integer NOT NULL,
starttime timestamp with time zone DEFAULT now() NOT NULL,
endtime timestamp with time zone,
CONSTRAINT auth_check CHECK (((endtime IS NULL) OR (starttime < endtime)))
);
COMMENT ON TABLE auth IS 'Grants users temporary permissions on the back end.';
COMMENT ON COLUMN auth.lookupid IS 'Permission granded to the user';
COMMENT ON COLUMN auth.endtime IS 'Permission runs out now; NULL = permenant.';
CREATE TABLE auth_group (
id integer NOT NULL,
name character varying(80) NOT NULL
);
CREATE SEQUENCE auth_group_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE auth_group_id_seq OWNED BY auth_group.id;
CREATE TABLE auth_officer (
officerid integer NOT NULL,
lookupid integer NOT NULL
);
COMMENT ON TABLE auth_officer IS 'Grants permanent back end permissions to people currently holding officer posts.';
CREATE TABLE auth_subnet (
typeid integer NOT NULL,
subnet cidr NOT NULL
);
COMMENT ON TABLE auth_subnet IS 'Allow users logged in from specific clients machines access to additional resources';
CREATE TABLE auth_trainingstatus (
typeid integer NOT NULL,
presenterstatusid integer NOT NULL
);
COMMENT ON TABLE auth_trainingstatus IS 'Permissions granted to users with the given training status';
CREATE TABLE auth_user (
id integer NOT NULL,
username character varying(30) NOT NULL,
first_name character varying(30) NOT NULL,
last_name character varying(30) NOT NULL,
email character varying(75) NOT NULL,
password character varying(128) NOT NULL,
is_staff boolean NOT NULL,
is_active boolean NOT NULL,
is_superuser boolean NOT NULL,
last_login timestamp with time zone NOT NULL,
date_joined timestamp with time zone NOT NULL
);
CREATE TABLE auth_user_groups (
id integer NOT NULL,
user_id integer NOT NULL,
group_id integer NOT NULL
);
CREATE SEQUENCE auth_user_groups_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE auth_user_groups_id_seq OWNED BY auth_user_groups.id;
CREATE SEQUENCE auth_user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE auth_user_id_seq OWNED BY auth_user.id;
CREATE SEQUENCE banner_category_categoryid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
CREATE TABLE baps_audio (
audioid integer NOT NULL,
trackid integer,
filename character varying(256) NOT NULL
);
CREATE SEQUENCE baps_audio_audioid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE baps_audio_audioid_seq OWNED BY baps_audio.audioid;
CREATE TABLE baps_audiolog (
audiologid integer NOT NULL,
serverid integer NOT NULL,
audioid integer NOT NULL,
timeplayed timestamp without time zone DEFAULT now() NOT NULL,
channel integer,
timestopped timestamp without time zone
);
CREATE SEQUENCE baps_audiolog_audiologid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE baps_audiolog_audiologid_seq OWNED BY baps_audiolog.audiologid;
CREATE TABLE baps_filefolder (
filefolderid integer NOT NULL,
workgroup character varying(40) NOT NULL,
server character varying(40) NOT NULL,
share character varying(40) NOT NULL,
username character varying(40),
password character varying(40),
public boolean DEFAULT false NOT NULL,
description character varying(255) NOT NULL,
owner integer NOT NULL
);
CREATE SEQUENCE baps_filefolder_filefolderid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE baps_filefolder_filefolderid_seq OWNED BY baps_filefolder.filefolderid;
CREATE TABLE baps_fileitem (
fileitemid integer NOT NULL,
filename character varying(511) NOT NULL
);
CREATE SEQUENCE baps_fileitem_fileitemid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE baps_fileitem_fileitemid_seq OWNED BY baps_fileitem.fileitemid;
CREATE TABLE baps_item (
itemid integer NOT NULL,
listingid integer NOT NULL,
name1 character varying(255) NOT NULL,
"position" integer NOT NULL,
textitemid integer,
libraryitemid integer,
fileitemid integer,
name2 character varying(255),
CONSTRAINT baps_item_check CHECK ((((((textitemid IS NULL) AND (libraryitemid IS NULL)) AND (fileitemid IS NOT NULL)) OR (((textitemid IS NOT NULL) AND (libraryitemid IS NULL)) AND (fileitemid IS NULL))) OR (((textitemid IS NULL) AND (libraryitemid IS NOT NULL)) AND (fileitemid IS NULL))))
);
CREATE SEQUENCE baps_item_itemid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE baps_item_itemid_seq OWNED BY baps_item.itemid;
CREATE TABLE baps_libraryitem (
libraryitemid integer NOT NULL,
recordid integer NOT NULL,
trackid integer NOT NULL
);
CREATE SEQUENCE baps_libraryitem_libraryitemid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE baps_libraryitem_libraryitemid_seq OWNED BY baps_libraryitem.libraryitemid;
CREATE TABLE baps_listing (
listingid integer NOT NULL,
showid integer NOT NULL,
name character varying(255) NOT NULL,
channel integer DEFAULT 0 NOT NULL
);
CREATE SEQUENCE baps_listing_listingid_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE baps_listing_listingid_seq OWNED BY baps_listing.listingid;
CREATE SEQUENCE baps_personal_collection_unique_id
START WITH 1
INCREMENT BY 1
NO MINVALUE
MAXVALUE 999999