mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Fix mysql migration
This commit is contained in:
parent
81192bfeca
commit
2df35026db
@ -15,47 +15,46 @@ DROP INDEX index_rating_folder_rated_id_fk ON rating_folder;
|
|||||||
|
|
||||||
|
|
||||||
ALTER TABLE folder
|
ALTER TABLE folder
|
||||||
ADD int_id INTEGER AFTER id,
|
ADD int_id INTEGER REFERENCES folder AFTER id,
|
||||||
ADD int_parent_id INTEGER REFERENCES folder AFTER parent_id;
|
ADD int_parent_id INTEGER REFERENCES folder AFTER parent_id;
|
||||||
UPDATE folder SET int_id = (SELECT id FROM folder_id_to_int WHERE uuid == folder.id);
|
UPDATE folder SET int_id = (SELECT id FROM folder_id_to_int WHERE uuid = folder.id);
|
||||||
UPDATE folder SET int_parent_id = (SELECT id FROM folder_id_to_int WHERE uuid == folder.parent_id);
|
UPDATE folder SET int_parent_id = (SELECT id FROM folder_id_to_int WHERE uuid = folder.parent_id);
|
||||||
ALTER TABLE folder
|
ALTER TABLE folder
|
||||||
DROP PRIMARY KEY,
|
DROP PRIMARY KEY,
|
||||||
DROP COLUMN id,
|
DROP COLUMN id,
|
||||||
DROP COLUMN parent_id,
|
DROP COLUMN parent_id,
|
||||||
RENAME COLUMN int_id TO id,
|
CHANGE COLUMN int_id id INTEGER AUTO_INCREMENT,
|
||||||
RENAME COLUMN int_parent_id TO parent_id,
|
CHANGE COLUMN int_parent_id parent_id INTEGER,
|
||||||
MODIFY id INTEGER AUTO_INCREMENT,
|
|
||||||
ADD PRIMARY KEY (id);
|
ADD PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE track
|
ALTER TABLE track
|
||||||
ADD int_root_folder_id INTEGER NOT NULL REFERENCES folder AFTER root_folder_id,
|
ADD int_root_folder_id INTEGER NOT NULL REFERENCES folder AFTER root_folder_id,
|
||||||
ADD int_folder_id INTEGER NOT NULL REFERENCES folder AFTER folder_id;
|
ADD int_folder_id INTEGER NOT NULL REFERENCES folder AFTER folder_id;
|
||||||
UPDATE track SET int_root_folder_id = (SELECT id FROM folder_id_to_int WHERE uuid == track.root_folder_id);
|
UPDATE track SET int_root_folder_id = (SELECT id FROM folder_id_to_int WHERE uuid = track.root_folder_id);
|
||||||
UPDATE track SET int_folder_id = (SELECT id FROM folder_id_to_int WHERE uuid == track.folder_id);
|
UPDATE track SET int_folder_id = (SELECT id FROM folder_id_to_int WHERE uuid = track.folder_id);
|
||||||
ALTER TABLE track
|
ALTER TABLE track
|
||||||
DROP COLUMN root_folder_id,
|
DROP COLUMN root_folder_id,
|
||||||
DROP COLUMN folder_id,
|
DROP COLUMN folder_id,
|
||||||
RENAME COLUMN int_root_folder_id TO root_folder_id,
|
CHANGE COLUMN int_root_folder_id root_folder_id INTEGER NOT NULL,
|
||||||
RENAME COLUMN int_folder_id TO folder_id,
|
CHANGE COLUMN int_folder_id folder_id INTEGER NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE starred_folder ADD int_starred_id INTEGER NOT NULL REFERENCES folder AFTER starred_id;
|
ALTER TABLE starred_folder ADD int_starred_id INTEGER NOT NULL REFERENCES folder AFTER starred_id;
|
||||||
UPDATE starred_folder SET int_starred_id = (SELECT id FROM folder_id_to_int WHERE uuid == starred_folder.starred_id);
|
UPDATE starred_folder SET int_starred_id = (SELECT id FROM folder_id_to_int WHERE uuid = starred_folder.starred_id);
|
||||||
ALTER TABLE starred_folder
|
ALTER TABLE starred_folder
|
||||||
DROP PRIMARY KEY,
|
DROP PRIMARY KEY,
|
||||||
DROP COLUMN starred_id,
|
DROP COLUMN starred_id,
|
||||||
RENAME COLUMN int_starred_id TO starred_id,
|
CHANGE COLUMN int_starred_id starred_id INTEGER NOT NULL,
|
||||||
ADD PRIMARY KEY (user_id, starred_id);
|
ADD PRIMARY KEY (user_id, starred_id);
|
||||||
|
|
||||||
|
|
||||||
ALTER TABLE rating_folder ADD int_rated_id INTEGER NOT NULL REFERENCES folder AFTER rated_id;
|
ALTER TABLE rating_folder ADD int_rated_id INTEGER NOT NULL REFERENCES folder AFTER rated_id;
|
||||||
UPDATE rating_folder SET int_rated_id = (SELECT id FROM folder_id_to_int WHERE uuid == rating_folder.rated_id);
|
UPDATE rating_folder SET int_rated_id = (SELECT id FROM folder_id_to_int WHERE uuid = rating_folder.rated_id);
|
||||||
ALTER TABLE rating_folder
|
ALTER TABLE rating_folder
|
||||||
DROP PRIMARY KEY,
|
DROP PRIMARY KEY,
|
||||||
DROP COLUMN rated_id,
|
DROP COLUMN rated_id,
|
||||||
RENAME COLUMN int_rated_id TO rated_id,
|
CHANGE COLUMN int_rated_id rated_id INTEGER NOT NULL,
|
||||||
ADD PRIMARY KEY (user_id, rated_id);
|
ADD PRIMARY KEY (user_id, rated_id);
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user