From caa4203748caabe68e8508cf8567dd595d89e881 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 28 Aug 2024 11:08:37 +0200 Subject: [PATCH 1/4] Fix psql collation mismatch --- scripts/_common.sh | 16 +++++++++++++++- scripts/upgrade | 7 +++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d902357..53fdfe8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -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;" diff --git a/scripts/upgrade b/scripts/upgrade index c6ffcff..1d608f8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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 #================================================= From b1d8d81640a0e0cc592ac031021dc7de1bc7d05c Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 28 Aug 2024 11:15:53 +0200 Subject: [PATCH 2/4] Update myynh_install_python --- scripts/_common.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 53fdfe8..c0040fd 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -66,7 +66,7 @@ myynh_install_python() { if $(dpkg --compare-versions $py_apt_version ge $python) then # APT >= Required - ynh_print_info --message="Using provided python3..." + ynh_print_info --message="Using OS provided python3..." py_app_version="python3" @@ -75,13 +75,13 @@ myynh_install_python() { if $(dpkg --compare-versions $py_built_version ge $python) then # Built >= Required - ynh_print_info --message="Using already used python3 built version..." + ynh_print_info --message="Using already python3 built version: $py_app_version" py_app_version="/usr/local/bin/python${py_built_version%.*}" else # APT < Minimal & Actual < Minimal => Build & install Python into /usr/local/bin - ynh_print_info --message="Building python (may take a while)..." + ynh_print_info --message="Building python3 : $python (may take a while)..." # Store current direcotry local MY_DIR=$(pwd) @@ -115,6 +115,10 @@ myynh_install_python() { fi # Save python version in settings ynh_app_setting_set --app=$app --key=python --value="$python" + + # Print some version information + ynh_print_info --message="Python version: $($py_app_version -VV)" + ynh_print_info --message="Pip version: $($py_app_version -m pip -V)" } # Install immich From 453e4319bd95d61c6698282605f4048be5f71fa5 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 28 Aug 2024 15:33:45 +0200 Subject: [PATCH 3/4] Fix myynh_install_python --- scripts/_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c0040fd..1b34b35 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -75,10 +75,10 @@ myynh_install_python() { if $(dpkg --compare-versions $py_built_version ge $python) then # Built >= Required - ynh_print_info --message="Using already python3 built version: $py_app_version" - py_app_version="/usr/local/bin/python${py_built_version%.*}" + ynh_print_info --message="Using already python3 built version: $py_app_version" + else # APT < Minimal & Actual < Minimal => Build & install Python into /usr/local/bin ynh_print_info --message="Building python3 : $python (may take a while)..." From 11652c991570d745dc151be21109a72aa7bf3851 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 28 Aug 2024 17:40:53 +0200 Subject: [PATCH 4/4] Fix myynh_update_psql_db --- scripts/_common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 1b34b35..86f3c49 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -274,8 +274,8 @@ myynh_create_psql_db() { 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" ] + if ynh_exec_warn_less myynh_execute_psql_as_root --sql=";" --database="$db" \ + | grep -q "collation version 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"