1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/immich_ynh.git synced 2024-09-03 20:36:24 +02:00

Fix psql collation mismatch

This commit is contained in:
Sylvain 2024-08-28 11:08:37 +02:00
parent 29883de18c
commit caa4203748
2 changed files with 22 additions and 1 deletions

View file

@ -249,7 +249,8 @@ myynh_execute_psql_as_root() {
ynh_handle_getopts_args "$@"
database="${database:-}"
if [ -n "$database" ]; then
if [ -n "$database" ]
then
database="--dbname=$database"
fi
@ -265,6 +266,19 @@ myynh_create_psql_db() {
myynh_execute_psql_as_root --sql="ALTER USER $app WITH SUPERUSER;" --database="$app"
}
# Update the database
myynh_update_psql_db() {
for db in postgres "$app"
do
test_collation_mismatch=$(ynh_exec_warn_less myynh_execute_psql_as_root --sql=";" --database="$db" | grep "collation version mismatch")
if [ -n "$test_collation_mismatch" ]
then
ynh_exec_warn_less myynh_execute_psql_as_root --sql="REINDEX DATABASE $db;" --database="$db"
myynh_execute_psql_as_root --sql="ALTER DATABASE $db REFRESH COLLATION VERSION;" --database="$db"
fi
done
}
# Remove the database
myynh_drop_psql_db() {
myynh_execute_psql_as_root --sql="REVOKE CONNECT ON DATABASE $app FROM public;"

View file

@ -49,6 +49,13 @@ ynh_script_progression --message="Installing nodejs..." --weight=1
ynh_exec_warn_less ynh_install_nodejs --nodejs_version="$nodejs_version"
#=================================================
# UPDATE A POSTGRESQL DATABASE
#=================================================
ynh_script_progression --message="Udpating a PostgreSQL database..." --weight=1
myynh_update_psql_db
#=================================================
# MAKE INSTALL
#=================================================