1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

Update scripts/upgrade

Co-authored-by: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com>
This commit is contained in:
eric_G 2024-01-10 19:33:45 +01:00 committed by GitHub
parent ce61682761
commit e724e98207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -66,24 +66,25 @@ exec_occ() {
# HANDLE DATABASE MIGRATION FROM MYSL TO PSQL # HANDLE DATABASE MIGRATION FROM MYSL TO PSQL
#================================================= #=================================================
mysql_db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) # If we're moving through version 28.0.1~ynh2 (in which the switch to psql is made)
if ynh_compare_current_package_version --comparison lt --version 28.0.1~ynh2
if [ -n "$mysql_db_pwd" ]
then then
ynh_script_progression --message="Migrating to PostgreSQL database..." --weight=3 # Double-check the mysql DB is here
if ! mysql -e "USE $db_name" 2>/dev/null
#ynh_backup_if_checksum_is_different --file="$install_dir/config/config.php" then
ynh_warn "Uhoh? The Nextcloud mysql DB doesn't exist ? We are supposed to move it to postgresql ... Maybe it was already migrated ?"
ynh_psql_test_if_first_run # Double check the psql is not empty, otherwise big whoops ?
ynh_psql_setup_db --db_user=$db_user --db_name=$db_name #--db_pwd=$(ynh_string_random) if [[ "$(ynh_psql_execute_as_root --database=$db_name --sql="\dt" 2>/dev/null | wc -l)" == 0 ]]
#ynh_app_setting_set --app=$app --key=psqlpwd --value=$db_pwd then
ynh_warn "Apparently the postgresql DB is not empty, so this is probably OK?"
exec_occ db:convert-type --all-apps --clear-schema pgsql $db_name 127.0.0.1 $db_name --password=$db_pwd -n else
ynh_die "Apparently the postgresql DB is also empty, this is kind of worrying, what happened?!"
ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name fi
ynh_app_setting_delete --app=$app --key=mysqlpwd else
ynh_script_info --message="Migrating to PostgreSQL database..." --weight=3
#ynh_store_file_checksum --file="${install_dir}/config/config.php" 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 fi
#================================================= #=================================================