From e1d5c72ed538a6ce4edac425c3fb7df709df0189 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 Upgrade: migrate old database scheme (#130) Co-authored-by: Nicolas Frandeboeuf --- migrations/foreign-keys-removal.sql | 12 ++++++++++++ scripts/upgrade | 11 +++++++++++ 2 files changed, 23 insertions(+) create mode 100644 migrations/foreign-keys-removal.sql diff --git a/migrations/foreign-keys-removal.sql b/migrations/foreign-keys-removal.sql new file mode 100644 index 0000000..0ebad2c --- /dev/null +++ b/migrations/foreign-keys-removal.sql @@ -0,0 +1,12 @@ +# Drop old foreign keys + +ALTER TABLE `oauth2_access_tokens` DROP FOREIGN KEY IF EXISTS FK_D247A21BA76ED395; +ALTER TABLE `oauth2_access_tokens` DROP FOREIGN KEY IF EXISTS FK_D247A21B19EB6921; +ALTER TABLE `oauth2_auth_codes` DROP FOREIGN KEY IF EXISTS FK_A018A10DA76ED395; +ALTER TABLE `oauth2_clients` DROP FOREIGN KEY IF EXISTS FK_F9D02AE6A76ED395; +ALTER TABLE `oauth2_refresh_tokens` DROP FOREIGN KEY IF EXISTS FK_D394478CA76ED395; +ALTER TABLE `config` DROP FOREIGN KEY IF EXISTS FK_D48A2F7CA76ED395; +ALTER TABLE `entry` DROP FOREIGN KEY IF EXISTS FK_2B219D70A76ED395; +ALTER TABLE `oauth2_auth_codes` DROP FOREIGN KEY IF EXISTS FK_A018A10D19EB6921; +ALTER TABLE `oauth2_refresh_tokens` DROP FOREIGN KEY IF EXISTS FK_D394478C19EB6921; +ALTER TABLE `tagging_rule` DROP FOREIGN KEY IF EXISTS FK_1AF95E7824DB0683; diff --git a/scripts/upgrade b/scripts/upgrade index 66cf800..b2ab10c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,17 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +# 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_exec_warn_less ynh_mysql_execute_file_as_root --database="$db_name" --file="../migrations/foreign-keys-removal.sql" +ynh_script_progression --message="Database migration done. Resuming normal upgrade process" --weight=11 + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #=================================================