Obelich
2/19/2019 - 11:26 PM

PostgresDesconect and block

#Disconect users on database
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname = '[DatabaseName]' -- ← change this to your DB
  AND pid <> pg_backend_pid();
# Block database conection
update pg_database set datallowconn = false where datname = '[DatabaseName]';