diff --git a/sbin/upgrade_database.py b/sbin/upgrade_database.py index 1a8993e..fef19b3 100755 --- a/sbin/upgrade_database.py +++ b/sbin/upgrade_database.py @@ -45,6 +45,11 @@ runner = "RUNNER_NOEXPORT=true RUNNER_IMPORT=true " + os.path.join(bin_path, "ru print(system_exports) os.system(system_exports) +print(f"Terminate all sessions in {dbname}") +cmd = f"psql -U {dbuser} -d {dbname} -c 'SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = current_database() AND pid <> pg_backend_pid();'" +print(cmd) +res = os.system(cmd) + cmd = f"psql -U {dbuser} -d template1 -c 'DROP DATABASE {dbname};'" print(cmd) res = os.system(cmd)