From 446f6ec7172367f933c1582b30e1cd8beeac230c Mon Sep 17 00:00:00 2001 From: lapineige Date: Mon, 14 Mar 2022 16:02:03 +0100 Subject: [PATCH] Upgrade old DB scheme Pre-2018 installation had a bad database scheme. This should fix it partly, and allow them to upgrade to wallabag 2.4.x. See : https://github.com/YunoHost-Apps/wallabag2_ynh/pull/125 --- scripts/upgrade | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index d9a1138..3581f74 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -158,6 +158,11 @@ then ynh_replace_string --match_string="database_table_prefix: wallabag_" --replace_string="database_table_prefix: null" --target_file=$wb_conf ynh_replace_string --match_string="secret: ovmpmAWXRCabNlMgzlzFXDYmCFfzGv" --replace_string="secret: $deskey" --target_file=$wb_conf ynh_replace_string --match_string="domain_name: https://your-wallabag-url-instance.com" --replace_string="domain_name: https://$domain$path_url" --target_file=$wb_conf + + # Migrate old (erroneous) database scheme (see: https://github.com/YunoHost-Apps/wallabag2_ynh/pull/125#issuecomment-1041426972) + ynh_script_progression --message="Migrating old (pre-2018) database scheme..." --weight=11 + ynh_mysql_execute_as_root --sql="START TRANSACTION; ALTER TABLE oauth2_access_tokens DROP FOREIGN KEY FK_D247A21BA76ED395; ALTER TABLE oauth2_access_tokens ADD CONSTRAINT FK_368A4209A76ED395 FOREIGN KEY (user_id) REFERENCES user (id); ALTER TABLE oauth2_access_tokens DROP FOREIGN KEY FK_D247A21B19EB6921; ALTER TABLE oauth2_access_tokens ADD CONSTRAINT FK_368A420919EB6921 FOREIGN KEY (client_id) REFERENCES oauth2_clients (id); ALTER TABLE oauth2_auth_codes DROP FOREIGN KEY FK_A018A10DA76ED395; ALTER TABLE oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FAA76ED395 FOREIGN KEY (user_id) REFERENCES user (id); ALTER TABLE oauth2_clients DROP FOREIGN KEY FK_F9D02AE6A76ED395; ALTER TABLE oauth2_clients ADD CONSTRAINT FK_635D765EA76ED395 FOREIGN KEY (`user_id`) REFERENCES `user` (`id`); ALTER TABLE oauth2_refresh_tokens DROP FOREIGN KEY FK_D394478CA76ED395; ALTER TABLE oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB24A76ED395 FOREIGN KEY (user_id) REFERENCES user (id); ALTER TABLE config DROP FOREIGN KEY FK_D48A2F7CA76ED395; ALTER TABLE config ADD CONSTRAINT FK_87E64C53A76ED395 FOREIGN KEY (user_id) REFERENCES user (id); ALTER TABLE entry DROP FOREIGN KEY FK_2B219D70A76ED395; ALTER TABLE entry ADD CONSTRAINT FK_F4D18282A76ED395 FOREIGN KEY (user_id) REFERENCES user (id); ALTER TABLE oauth2_auth_codes DROP FOREIGN KEY FK_A018A10D19EB6921; ALTER TABLE oauth2_auth_codes ADD CONSTRAINT FK_EE52E3FA19EB6921 FOREIGN KEY (client_id) REFERENCES oauth2_clients (id); ALTER TABLE oauth2_refresh_tokens DROP FOREIGN KEY FK_D394478C19EB6921; ALTER TABLE oauth2_refresh_tokens ADD CONSTRAINT FK_20C9FB2419EB6921 FOREIGN KEY (client_id) REFERENCES oauth2_clients (id); ALTER TABLE tagging_rule DROP FOREIGN KEY FK_1AF95E7824DB0683; ALTER TABLE tagging_rule ADD CONSTRAINT FK_2D9B3C5424DB0683 FOREIGN KEY (config_id) REFERENCES config (id); COMMIT;" --database=$db_name + ynh_script_progression --message="Database migration done. Resuming normal upgrade process" --weight=11 #================================================= # UPGRADE WALLABAG