From dc19e579ff8731848bb46e401162ce7fdcf86ab3 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 22 Apr 2019 14:31:38 +0200 Subject: [PATCH] Add comment explaining the mystic incantation --- data/helpers.d/psql | 3 +++ 1 file changed, 3 insertions(+) diff --git a/data/helpers.d/psql b/data/helpers.d/psql index dc83cc0e8..a5bccedd6 100644 --- a/data/helpers.d/psql +++ b/data/helpers.d/psql @@ -105,6 +105,9 @@ ynh_psql_create_db() { # Requires YunoHost version 3.?.? or higher. ynh_psql_drop_db() { local db=$1 + # First, force disconnection of all clients connected to the database + # https://stackoverflow.com/questions/5408156/how-to-drop-a-postgresql-database-if-there-are-active-connections-to-it + # https://dba.stackexchange.com/questions/16426/how-to-drop-all-connections-to-a-specific-database-without-stopping-the-server ynh_psql_execute_as_root --sql="SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db';" --database="$db" sudo --login --user=postgres dropdb $db }