mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Revoke before drop
This commit is contained in:
parent
8085b3a2c2
commit
db0d748f62
1 changed files with 3 additions and 3 deletions
|
@ -107,9 +107,9 @@ ynh_psql_create_db() {
|
|||
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"
|
||||
# https://stackoverflow.com/questions/17449420/postgresql-unable-to-drop-database-because-of-some-auto-connections-to-db
|
||||
ynh_psql_execute_as_root --sql="REVOKE CONNECT ON DATABASE $db FROM public;" --database="$db"
|
||||
ynh_psql_execute_as_root --sql="SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$db' AND pid <> pg_backend_pid();" --database="$db"
|
||||
sudo --login --user=postgres dropdb $db
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue