From b4fcf41f417252e8af81b01bbf023427354fc83d Mon Sep 17 00:00:00 2001 From: Kay0u Date: Tue, 7 Mar 2023 09:52:10 +0100 Subject: [PATCH] delete the psql db if the migration fails --- scripts/upgrade | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index da97e36..aeb0f14 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,6 +56,10 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + # Remove the PostgreSQL db in case of error during the migration. + if [ -n "$remove_psql_in_case_of_error" ]; then + ynh_psql_remove_db --db_user=$db_user --db_name=$db_name + fi # Restore it if the upgrade fails ynh_restore_upgradebackup } @@ -118,6 +122,7 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies if mysqlshow | grep -q "^| $db_name "; then # Mattermost only support MySQL and PostgreSQL (not MariaDB...) # Migrate the database from MariaDB to PostgreSQL + remove_psql_in_case_of_error=1 mariadb-to-pg fi