mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 03:47:23 +01:00
Add initial database including simple abstractions
This commit is contained in:
parent
868e1168e5
commit
c67cefb38a
12 changed files with 772 additions and 0 deletions
19
migrations/2020-09-27-201047_initial_schema/down.sql
Normal file
19
migrations/2020-09-27-201047_initial_schema/down.sql
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
DROP TABLE persons;
|
||||
|
||||
DROP TABLE instruments;
|
||||
|
||||
DROP TABLE works;
|
||||
|
||||
DROP TABLE instrumentations;
|
||||
|
||||
DROP TABLE work_parts;
|
||||
|
||||
DROP TABLE part_instrumentations;
|
||||
|
||||
DROP TABLE work_sections;
|
||||
|
||||
DROP TABLE ensembles;
|
||||
|
||||
DROP TABLE recordings;
|
||||
|
||||
DROP TABLE performances;
|
||||
62
migrations/2020-09-27-201047_initial_schema/up.sql
Normal file
62
migrations/2020-09-27-201047_initial_schema/up.sql
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
CREATE TABLE persons (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
first_name TEXT NOT NULL,
|
||||
last_name TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE instruments (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE works (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
composer BIGINT NOT NULL REFERENCES persons(id) ON DELETE CASCADE,
|
||||
title TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE instrumentations (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
work BIGINT NOT NULL REFERENCES works(id) ON DELETE CASCADE,
|
||||
instrument BIGINT NOT NULL REFERENCES instruments(id)
|
||||
);
|
||||
|
||||
CREATE TABLE work_parts (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
work BIGINT NOT NULL REFERENCES works(id) ON DELETE CASCADE,
|
||||
part_index BIGINT NOT NULL,
|
||||
composer BIGINT REFERENCES persons(id),
|
||||
title TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE part_instrumentations (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
work_part BIGINT NOT NULL REFERENCES works(id) ON DELETE CASCADE,
|
||||
instrument BIGINT NOT NULL REFERENCES instruments(id)
|
||||
);
|
||||
|
||||
CREATE TABLE work_sections (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
work BIGINT NOT NULL REFERENCES works(id) ON DELETE CASCADE,
|
||||
title TEXT NOT NULL,
|
||||
before_index BIGINT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE ensembles (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
name TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE recordings (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
work BIGINT NOT NULL REFERENCES works(id) ON DELETE CASCADE,
|
||||
comment TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE performances (
|
||||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
recording BIGINT NOT NULL REFERENCES recordings(id) ON DELETE CASCADE,
|
||||
person BIGINT REFERENCES persons(id) ON DELETE CASCADE,
|
||||
ensemble BIGINT REFERENCES ensembles(id) ON DELETE CASCADE,
|
||||
role BIGINT REFERENCES instruments(id)
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue