btrtracks/migrations/001-initial.sql

34 lines
630 B
MySQL
Raw Normal View History

2018-10-05 10:36:57 +00:00
-- 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;