update schema init script
This commit is contained in:
parent
1667921f5b
commit
d0b392f6a0
34
schema.sql
34
schema.sql
|
@ -1,18 +1,18 @@
|
||||||
--
|
--
|
||||||
-- Artists (should be applicable to all art)
|
-- Artists (should be applicable to all art)
|
||||||
--
|
--
|
||||||
CREATE TABLE public.artist (
|
CREATE TABLE artist (
|
||||||
id character varying(64),
|
id character varying(64),
|
||||||
name text NOT NULL,
|
name text NOT NULL,
|
||||||
website text,
|
website text,
|
||||||
avatar text
|
avatar text
|
||||||
);
|
);
|
||||||
ALTER TABLE public.artist ADD CONSTRAINT artist_pk PRIMARY KEY (id);
|
ALTER TABLE artist ADD CONSTRAINT artist_pk PRIMARY KEY (id);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Music releases
|
-- Music releases
|
||||||
--
|
--
|
||||||
CREATE TABLE public.musicrelease (
|
CREATE TABLE musicrelease (
|
||||||
id character varying(64) NOT NULL,
|
id character varying(64) NOT NULL,
|
||||||
visible bool DEFAULT false,
|
visible bool DEFAULT false,
|
||||||
title text NOT NULL,
|
title text NOT NULL,
|
||||||
|
@ -25,56 +25,56 @@ CREATE TABLE public.musicrelease (
|
||||||
copyright text,
|
copyright text,
|
||||||
copyrightURL text
|
copyrightURL text
|
||||||
);
|
);
|
||||||
ALTER TABLE public.musicrelease ADD CONSTRAINT musicrelease_pk PRIMARY KEY (id);
|
ALTER TABLE musicrelease ADD CONSTRAINT musicrelease_pk PRIMARY KEY (id);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Music links (external platform links under a release)
|
-- Music links (external platform links under a release)
|
||||||
--
|
--
|
||||||
CREATE TABLE public.musiclink (
|
CREATE TABLE musiclink (
|
||||||
release character varying(64) NOT NULL,
|
release character varying(64) NOT NULL,
|
||||||
name text NOT NULL,
|
name text NOT NULL,
|
||||||
url text NOT NULL
|
url text NOT NULL
|
||||||
);
|
);
|
||||||
ALTER TABLE public.musiclink ADD CONSTRAINT musiclink_pk PRIMARY KEY (release, name);
|
ALTER TABLE musiclink ADD CONSTRAINT musiclink_pk PRIMARY KEY (release, name);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Music credits (artist credits under a release)
|
-- Music credits (artist credits under a release)
|
||||||
--
|
--
|
||||||
CREATE TABLE public.musiccredit (
|
CREATE TABLE musiccredit (
|
||||||
release character varying(64) NOT NULL,
|
release character varying(64) NOT NULL,
|
||||||
artist character varying(64) NOT NULL,
|
artist character varying(64) NOT NULL,
|
||||||
role text NOT NULL,
|
role text NOT NULL,
|
||||||
is_primary boolean DEFAULT false
|
is_primary boolean DEFAULT false
|
||||||
);
|
);
|
||||||
ALTER TABLE public.musiccredit ADD CONSTRAINT musiccredit_pk PRIMARY KEY (release, artist);
|
ALTER TABLE musiccredit ADD CONSTRAINT musiccredit_pk PRIMARY KEY (release, artist);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Music tracks (tracks under a release)
|
-- Music tracks (tracks under a release)
|
||||||
--
|
--
|
||||||
CREATE TABLE public.musictrack (
|
CREATE TABLE musictrack (
|
||||||
id uuid DEFAULT gen_random_uuid(),
|
id uuid DEFAULT gen_random_uuid(),
|
||||||
title text NOT NULL,
|
title text NOT NULL,
|
||||||
description text,
|
description text,
|
||||||
lyrics text,
|
lyrics text,
|
||||||
preview_url text
|
preview_url text
|
||||||
);
|
);
|
||||||
ALTER TABLE public.musictrack ADD CONSTRAINT musictrack_pk PRIMARY KEY (id);
|
ALTER TABLE musictrack ADD CONSTRAINT musictrack_pk PRIMARY KEY (id);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Music release/track pairs
|
-- Music release/track pairs
|
||||||
--
|
--
|
||||||
CREATE TABLE public.musicreleasetrack (
|
CREATE TABLE musicreleasetrack (
|
||||||
release character varying(64) NOT NULL,
|
release character varying(64) NOT NULL,
|
||||||
track uuid NOT NULL,
|
track uuid NOT NULL,
|
||||||
number integer NOT NULL
|
number integer NOT NULL
|
||||||
);
|
);
|
||||||
ALTER TABLE public.musicreleasetrack ADD CONSTRAINT musicreleasetrack_pk PRIMARY KEY (release, track);
|
ALTER TABLE musicreleasetrack ADD CONSTRAINT musicreleasetrack_pk PRIMARY KEY (release, track);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Foreign keys
|
-- Foreign keys
|
||||||
--
|
--
|
||||||
ALTER TABLE public.musiccredit ADD CONSTRAINT musiccredit_artist_fk FOREIGN KEY (artist) REFERENCES public.artist(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
ALTER TABLE musiccredit ADD CONSTRAINT musiccredit_artist_fk FOREIGN KEY (artist) REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
ALTER TABLE public.musiccredit ADD CONSTRAINT musiccredit_release_fk FOREIGN KEY (release) REFERENCES public.musicrelease(id) ON DELETE CASCADE;
|
ALTER TABLE musiccredit ADD CONSTRAINT musiccredit_release_fk FOREIGN KEY (release) REFERENCES musicrelease(id) ON DELETE CASCADE;
|
||||||
ALTER TABLE public.musiclink ADD CONSTRAINT musiclink_release_fk FOREIGN KEY (release) REFERENCES public.musicrelease(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
ALTER TABLE musiclink ADD CONSTRAINT musiclink_release_fk FOREIGN KEY (release) REFERENCES musicrelease(id) ON UPDATE CASCADE ON DELETE CASCADE;
|
||||||
ALTER TABLE public.musicreleasetrack ADD CONSTRAINT music_pair_trackref_fk FOREIGN KEY (release) REFERENCES public.musicrelease(id) ON DELETE CASCADE;
|
ALTER TABLE musicreleasetrack ADD CONSTRAINT music_pair_trackref_fk FOREIGN KEY (release) REFERENCES musicrelease(id) ON DELETE CASCADE;
|
||||||
ALTER TABLE public.musicreleasetrack ADD CONSTRAINT music_pair_releaseref_fk FOREIGN KEY (track) REFERENCES public.musictrack(id) ON DELETE CASCADE;
|
ALTER TABLE musicreleasetrack ADD CONSTRAINT music_pair_releaseref_fk FOREIGN KEY (track) REFERENCES musictrack(id) ON DELETE CASCADE;
|
||||||
|
|
Loading…
Reference in a new issue