diff --git a/src/db/migrations/201707091522_playlists_tables/down.sql b/src/db/migrations/201707091522_playlists_tables/down.sql new file mode 100644 index 0000000..8060d04 --- /dev/null +++ b/src/db/migrations/201707091522_playlists_tables/down.sql @@ -0,0 +1,2 @@ +DROP TABLE playlists; +DROP TABLE playlist_songs; diff --git a/src/db/migrations/201707091522_playlists_tables/up.sql b/src/db/migrations/201707091522_playlists_tables/up.sql new file mode 100644 index 0000000..bfa0723 --- /dev/null +++ b/src/db/migrations/201707091522_playlists_tables/up.sql @@ -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) +); diff --git a/src/db/schema.sqlite b/src/db/schema.sqlite index eabf4ac..84aa6e4 100644 Binary files a/src/db/schema.sqlite and b/src/db/schema.sqlite differ