31 lines
645 B
SQL
31 lines
645 B
SQL
-- Up
|
|
|
|
CREATE TABLE User (
|
|
id INTEGER PRIMARY KEY,
|
|
username TEXT,
|
|
password TEXT,
|
|
email TEXT,
|
|
image TEXT,
|
|
created TEXT
|
|
);
|
|
|
|
CREATE TABLE OAuth (
|
|
id INTEGER PRIMARY KEY,
|
|
userId INTEGER,
|
|
remoteId TEXT,
|
|
created TEXT,
|
|
CONSTRAINT PE_fk_userId FOREIGN KEY (userId)
|
|
REFERENCES User (id) ON UPDATE CASCADE ON DELETE CASCADE
|
|
);
|
|
|
|
ALTER TABLE Track ADD COLUMN userId INTEGER;
|
|
ALTER TABLE Playlist ADD COLUMN userId INTEGER;
|
|
ALTER TABLE PlaylistEntry ADD COLUMN userId INTEGER;
|
|
|
|
-- Down
|
|
DROP TABLE User;
|
|
DROP TABLE OAuth;
|
|
ALTER TABLE Track DROP COLUMN userId;
|
|
ALTER TABLE Playlist DROP COLUMN userId;
|
|
ALTER TABLE PlaylistEntry DROP COLUMN userId;
|