From 4d8b668ebfa7cb4a1d3cd06780bfb2b1f64d830c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:49:58 +0200 Subject: [PATCH] Update upgrade --- scripts/upgrade | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 5f1e665..089b847 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -75,26 +75,26 @@ exec_occ() { # HANDLE DATABASE MIGRATION FROM MYSL TO PSQL #================================================= -# # If we're moving through version 29.0.3~ynh1 (in which the switch to psql is made) -# if ynh_compare_current_package_version --comparison lt --version 29.0.3~ynh1 -# then -# # Double-check the MySQL DB is here -# if ! mysql -e "USE $db_name" 2>/dev/null -# then -# ynh_print_warn "Uhoh? The Nextcloud MySQL DB doesn't exist? We are supposed to move it to PostgreSQL... Maybe it was already migrated?" -# # Double check the psql is not empty, otherwise big whoops? -# if [[ "$(ynh_psql_execute_as_root --database=$db_name --sql="\dt" 2>/dev/null | wc -l)" == 0 ]] -# then -# ynh_die "Apparently the PostgreSQL DB is also empty, this is kind of worrying, what happened?!" -# else -# ynh_print_warn "Apparently the PostgreSQL DB is not empty, so this is probably OK?" -# fi -# else -# ynh_print_info --message="Migrating to PostgreSQL database..." -# ynh_exec_warn_less exec_occ db:convert-type --all-apps --clear-schema pgsql $db_name 127.0.0.1 $db_name --password=$db_pwd -n -# ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name -# fi -# fi +# If we're moving through version 29.0.3~ynh1 (in which the switch to psql is made) +if ynh_compare_current_package_version --comparison lt --version 29.0.3~ynh1 +then + # Double-check the MySQL DB is here + if ! mysql -e "USE $db_name" 2>/dev/null + then + ynh_print_warn "Uhoh? The Nextcloud MySQL DB doesn't exist? We are supposed to move it to PostgreSQL... Maybe it was already migrated?" + # Double check the psql is not empty, otherwise big whoops? + if [[ "$(ynh_psql_execute_as_root --database=$db_name --sql="\dt" 2>/dev/null | wc -l)" == 0 ]] + then + ynh_die "Apparently the PostgreSQL DB is also empty, this is kind of worrying, what happened?!" + else + ynh_print_warn "Apparently the PostgreSQL DB is not empty, so this is probably OK?" + fi + else + ynh_print_info --message="Migrating to PostgreSQL database..." + ynh_exec_warn_less exec_occ db:convert-type --all-apps --clear-schema pgsql $db_name 127.0.0.1 $db_name --password=$db_pwd -n + ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name + fi +fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE