Fix sqlite migration for configuration

This commit is contained in:
Jan Eitzinger 2023-06-30 09:15:58 +02:00
parent b6be76eb07
commit b5a7249ad5
2 changed files with 20 additions and 8 deletions

View File

@ -1,4 +1,10 @@
ALTER TABLE configuration ADD COLUMN value_new varchar(255); CREATE TABLE IF NOT EXISTS configuration_new (
INSERT INTO configuration (value_new) SELECT value FROM configuration; username varchar(255),
ALTER TABLE configuration DROP COLUMN value; confkey varchar(255),
ALTER TABLE configuration RENAME COLUMN value_new TO value; value varchar(255),
PRIMARY KEY (username, confkey),
FOREIGN KEY (username) REFERENCES user (username) ON DELETE CASCADE ON UPDATE NO ACTION);
INSERT INTO configuration_new SELECT * FROM configuration;
DROP TABLE configuration;
ALTER TABLE configuration_new RENAME TO configuration;

View File

@ -1,4 +1,10 @@
ALTER TABLE configuration ADD COLUMN value_new TEXT; CREATE TABLE IF NOT EXISTS configuration_new (
INSERT INTO configuration (value_new) SELECT value FROM configuration; username varchar(255),
ALTER TABLE configuration DROP COLUMN value; confkey varchar(255),
ALTER TABLE configuration RENAME COLUMN value_new TO value; value text,
PRIMARY KEY (username, confkey),
FOREIGN KEY (username) REFERENCES user (username) ON DELETE CASCADE ON UPDATE NO ACTION);
INSERT INTO configuration_new SELECT * FROM configuration;
DROP TABLE configuration;
ALTER TABLE configuration_new RENAME TO configuration;