From 448fe5390992eab205f5826317ad30155c0a2ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Sun, 14 Jul 2024 22:08:49 +0200 Subject: [PATCH] Set user as superuser in postgresql temporarily --- scripts/install | 7 +++++-- scripts/upgrade | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 96fb607..ef0ae5b 100755 --- a/scripts/install +++ b/scripts/install @@ -46,7 +46,7 @@ ynh_script_progression --message="Building ToolJet..." --weight=10 pushd $install_dir ynh_use_nodejs - # The version shipped by default with n does not work, there is a + # The version shipped by default with n does not work, there is a # weird dependency issue about unsupported platform and fsevent. # See https://github.com/ToolJet/ToolJet/pull/1752 $ynh_npm install npm@"$NPM_VERSION" --location=global @@ -94,7 +94,10 @@ ynh_script_progression --message="Building ToolJet database..." --weight=1 pushd $install_dir # Build the database once the configuration is set - ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run db:migrate + # Need superuser because it uses a temporary database... + ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name" + ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run db:migrate + ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name" popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 0908be5..863b90d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -67,7 +67,7 @@ ynh_script_progression --message="Building ToolJet..." --weight=10 pushd $install_dir ynh_use_nodejs - # The version shipped by default with n does not work, there is a + # The version shipped by default with n does not work, there is a # wierd dependency issue about unsupported platform and fsevent. # See https://github.com/ToolJet/ToolJet/pull/1752 $ynh_npm install npm@"$NPM_VERSION" --location=global @@ -101,7 +101,10 @@ ynh_script_progression --message="Building ToolJet database..." --weight=1 pushd $install_dir # Build the database once the configuration is set - ynh_exec_as $app $ynh_node_load_PATH $ynh_npm run db:migrate + # Need superuser because it uses a temporary database... + ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH SUPERUSER;" --database="$db_name" + ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" run db:migrate + ynh_psql_execute_as_root --sql="ALTER USER $db_user WITH NOSUPERUSER;" --database="$db_name" popd #=================================================