Added playlists tables
This commit is contained in:
parent
eb5900fb7d
commit
d184802130
3 changed files with 19 additions and 0 deletions
2
src/db/migrations/201707091522_playlists_tables/down.sql
Normal file
2
src/db/migrations/201707091522_playlists_tables/down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
DROP TABLE playlists;
|
||||
DROP TABLE playlist_songs;
|
17
src/db/migrations/201707091522_playlists_tables/up.sql
Normal file
17
src/db/migrations/201707091522_playlists_tables/up.sql
Normal file
|
@ -0,0 +1,17 @@
|
|||
CREATE TABLE playlists (
|
||||
id INTEGER PRIMARY KEY NOT NULL,
|
||||
owner INTEGER NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
FOREIGN KEY(owner) REFERENCES users(id) ON DELETE CASCADE,
|
||||
UNIQUE(owner, name)
|
||||
);
|
||||
|
||||
CREATE TABLE playlist_songs (
|
||||
id INTEGER PRIMARY KEY NOT NULL,
|
||||
playlist INTEGER NOT NULL,
|
||||
path TEXT NOT NULL,
|
||||
ordering INTEGER NOT NULL,
|
||||
FOREIGN KEY(path) REFERENCES songs(path) ON DELETE NO ACTION,
|
||||
FOREIGN KEY(playlist) REFERENCES playlists(id) ON DELETE CASCADE,
|
||||
UNIQUE(playlist, ordering)
|
||||
);
|
Binary file not shown.
Loading…
Add table
Reference in a new issue