mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56: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
|
||||
ADD int_id INTEGER AFTER id,
|
||||
ADD int_id INTEGER REFERENCES folder AFTER 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_parent_id = (SELECT id FROM folder_id_to_int WHERE uuid == folder.parent_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);
|
||||
ALTER TABLE folder
|
||||
DROP PRIMARY KEY,
|
||||
DROP COLUMN id,
|
||||
DROP COLUMN parent_id,
|
||||
RENAME COLUMN int_id TO id,
|
||||
RENAME COLUMN int_parent_id TO parent_id,
|
||||
MODIFY id INTEGER AUTO_INCREMENT,
|
||||
CHANGE COLUMN int_id id INTEGER AUTO_INCREMENT,
|
||||
CHANGE COLUMN int_parent_id parent_id INTEGER,
|
||||
ADD PRIMARY KEY (id);
|
||||
|
||||
|
||||
ALTER TABLE track
|
||||
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;
|
||||
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_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);
|
||||
ALTER TABLE track
|
||||
DROP COLUMN root_folder_id,
|
||||
DROP COLUMN folder_id,
|
||||
RENAME COLUMN int_root_folder_id TO root_folder_id,
|
||||
RENAME COLUMN int_folder_id TO folder_id,
|
||||
CHANGE COLUMN int_root_folder_id root_folder_id INTEGER NOT NULL,
|
||||
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;
|
||||
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
|
||||
DROP PRIMARY KEY,
|
||||
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);
|
||||
|
||||
|
||||
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
|
||||
DROP PRIMARY KEY,
|
||||
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);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user