btrtracks/migrations/001-initial.sql
2018-10-05 13:36:57 +03:00

34 lines
630 B
SQL

-- Up
CREATE TABLE Playlist (
id INTEGER PRIMARY KEY,
title TEXT
);
CREATE TABLE Track (
id INTEGER PRIMARY KEY,
title TEXT,
artist TEXT,
file TEXT,
album TEXT,
genre TEXT,
track INTEGER,
year INTEGER,
duration INTEGER
);
CREATE TABLE PlaylistEntry (
id INTEGER PRIMARY KEY,
playlistId INTEGER,
trackId INTEGER,
CONSTRAINT PE_fk_playlistId FOREIGN KEY (playlistId)
REFERENCES Playlist (id) ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT PE_fk_trackId FOREIGN KEY (trackId)
REFERENCES Track (id) ON UPDATE CASCADE ON DELETE CASCADE
);
-- Down
DROP TABLE Playlist;
DROP TABLE Track;
DROP TABLE PlaylistEntry;