2024-08-01 00:39:18 +00:00
|
|
|
--
|
|
|
|
-- Artists (should be applicable to all art)
|
|
|
|
--
|
2024-11-10 00:18:52 +00:00
|
|
|
CREATE TABLE artist (
|
2024-08-02 23:27:30 +00:00
|
|
|
id character varying(64),
|
2024-08-01 23:53:19 +00:00
|
|
|
name text NOT NULL,
|
|
|
|
website text,
|
|
|
|
avatar text
|
2024-07-31 03:09:22 +00:00
|
|
|
);
|
2024-11-10 00:18:52 +00:00
|
|
|
ALTER TABLE artist ADD CONSTRAINT artist_pk PRIMARY KEY (id);
|
2024-07-31 03:09:22 +00:00
|
|
|
|
2024-08-01 00:39:18 +00:00
|
|
|
--
|
|
|
|
-- Music releases
|
|
|
|
--
|
2024-11-10 00:18:52 +00:00
|
|
|
CREATE TABLE musicrelease (
|
2024-07-31 03:09:22 +00:00
|
|
|
id character varying(64) NOT NULL,
|
2024-08-02 21:48:26 +00:00
|
|
|
visible bool DEFAULT false,
|
2024-07-31 03:09:22 +00:00
|
|
|
title text NOT NULL,
|
2024-08-01 00:39:18 +00:00
|
|
|
description text,
|
2024-07-31 03:09:22 +00:00
|
|
|
type text,
|
2024-08-05 00:23:17 +00:00
|
|
|
release_date TIMESTAMP NOT NULL,
|
2024-07-31 03:09:22 +00:00
|
|
|
artwork text,
|
|
|
|
buyname text,
|
2024-09-01 03:43:32 +00:00
|
|
|
buylink text,
|
|
|
|
copyright text,
|
|
|
|
copyrightURL text
|
2024-07-31 03:09:22 +00:00
|
|
|
);
|
2024-11-10 00:18:52 +00:00
|
|
|
ALTER TABLE musicrelease ADD CONSTRAINT musicrelease_pk PRIMARY KEY (id);
|
2024-07-31 03:09:22 +00:00
|
|
|
|
2024-08-01 00:39:18 +00:00
|
|
|
--
|
|
|
|
-- Music links (external platform links under a release)
|
|
|
|
--
|
2024-11-10 00:18:52 +00:00
|
|
|
CREATE TABLE musiclink (
|
2024-07-31 03:09:22 +00:00
|
|
|
release character varying(64) NOT NULL,
|
|
|
|
name text NOT NULL,
|
2024-08-01 23:53:19 +00:00
|
|
|
url text NOT NULL
|
2024-07-31 03:09:22 +00:00
|
|
|
);
|
2024-11-10 00:18:52 +00:00
|
|
|
ALTER TABLE musiclink ADD CONSTRAINT musiclink_pk PRIMARY KEY (release, name);
|
2024-07-31 03:09:22 +00:00
|
|
|
|
2024-08-01 00:39:18 +00:00
|
|
|
--
|
|
|
|
-- Music credits (artist credits under a release)
|
|
|
|
--
|
2024-11-10 00:18:52 +00:00
|
|
|
CREATE TABLE musiccredit (
|
2024-07-31 03:09:22 +00:00
|
|
|
release character varying(64) NOT NULL,
|
2024-08-02 21:48:26 +00:00
|
|
|
artist character varying(64) NOT NULL,
|
2024-08-01 23:53:19 +00:00
|
|
|
role text NOT NULL,
|
|
|
|
is_primary boolean DEFAULT false
|
2024-07-31 03:09:22 +00:00
|
|
|
);
|
2024-11-10 00:18:52 +00:00
|
|
|
ALTER TABLE musiccredit ADD CONSTRAINT musiccredit_pk PRIMARY KEY (release, artist);
|
2024-07-31 03:09:22 +00:00
|
|
|
|
2024-08-01 00:39:18 +00:00
|
|
|
--
|
|
|
|
-- Music tracks (tracks under a release)
|
|
|
|
--
|
2024-11-10 00:18:52 +00:00
|
|
|
CREATE TABLE musictrack (
|
2024-08-01 23:53:19 +00:00
|
|
|
id uuid DEFAULT gen_random_uuid(),
|
2024-07-31 03:09:22 +00:00
|
|
|
title text NOT NULL,
|
|
|
|
description text,
|
|
|
|
lyrics text,
|
2024-07-31 12:45:34 +00:00
|
|
|
preview_url text
|
2024-07-31 03:09:22 +00:00
|
|
|
);
|
2024-11-10 00:18:52 +00:00
|
|
|
ALTER TABLE musictrack ADD CONSTRAINT musictrack_pk PRIMARY KEY (id);
|
2024-07-31 03:09:22 +00:00
|
|
|
|
2024-08-01 00:39:18 +00:00
|
|
|
--
|
2024-08-01 23:53:19 +00:00
|
|
|
-- Music release/track pairs
|
2024-08-01 00:39:18 +00:00
|
|
|
--
|
2024-11-10 00:18:52 +00:00
|
|
|
CREATE TABLE musicreleasetrack (
|
2024-08-01 23:53:19 +00:00
|
|
|
release character varying(64) NOT NULL,
|
|
|
|
track uuid NOT NULL,
|
|
|
|
number integer NOT NULL
|
|
|
|
);
|
2024-11-10 00:18:52 +00:00
|
|
|
ALTER TABLE musicreleasetrack ADD CONSTRAINT musicreleasetrack_pk PRIMARY KEY (release, track);
|
2024-07-31 03:09:22 +00:00
|
|
|
|
2024-08-01 23:53:19 +00:00
|
|
|
--
|
|
|
|
-- Foreign keys
|
|
|
|
--
|
2024-11-10 00:18:52 +00:00
|
|
|
ALTER TABLE musiccredit ADD CONSTRAINT musiccredit_artist_fk FOREIGN KEY (artist) REFERENCES artist(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
|
|
|
ALTER TABLE musiccredit ADD CONSTRAINT musiccredit_release_fk FOREIGN KEY (release) REFERENCES musicrelease(id) 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 musicreleasetrack ADD CONSTRAINT music_pair_trackref_fk FOREIGN KEY (release) REFERENCES musicrelease(id) ON DELETE CASCADE;
|
|
|
|
ALTER TABLE musicreleasetrack ADD CONSTRAINT music_pair_releaseref_fk FOREIGN KEY (track) REFERENCES musictrack(id) ON DELETE CASCADE;
|