diff --git a/scripts/upgrade b/scripts/upgrade index 2532985..e82b65d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -36,6 +36,15 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) # ENSURE DOWNWARD COMPATIBILITY #================================================= +# Previous versions did not set the DB name as a setting, so we need to set it now (will be used on +# remove). +if [ -z "$db_name" ] +then + db_name=$(ynh_sanitize_dbid --db_name=$app) + ynh_app_setting_set --app=$app --key=db_name --value=$db_name + db_user=$db_name +fi + # If final_path doesn't exist, create it if [ -z "$final_path" ] then @@ -83,10 +92,6 @@ ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies if [ -z "$db_pwd" ] then ynh_script_progression --message="Setting up database" - db_name=$(ynh_sanitize_dbid --db_name=$app) - db_user=$db_name - ynh_app_setting_set --app=$app --key=db_name --value=$db_name - ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)