summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Siraut <csiraut@entrouvert.com>2019-06-05 07:33:37 (GMT)
committerChristophe Siraut <csiraut@entrouvert.com>2019-06-05 07:33:37 (GMT)
commit6fd3afc1f0fce2d706441048f25150121919f96b (patch)
treefa02c3b732b6057eb629285748ea78ac07f477c4
parent4f116fcdebe1b70391214c54fa6e79006f7baed9 (diff)
downloadpublik-client-scripts-6fd3afc1f0fce2d706441048f25150121919f96b.zip
publik-client-scripts-6fd3afc1f0fce2d706441048f25150121919f96b.tar.gz
publik-client-scripts-6fd3afc1f0fce2d706441048f25150121919f96b.tar.bz2
montpellier: drop connections before dropping database (#33681)
-rwxr-xr-xclients/montpellier/pg_copy_bijoe_schema1
1 files changed, 1 insertions, 0 deletions
diff --git a/clients/montpellier/pg_copy_bijoe_schema b/clients/montpellier/pg_copy_bijoe_schema
index a102fb2..5c04c7a 100755
--- a/clients/montpellier/pg_copy_bijoe_schema
+++ b/clients/montpellier/pg_copy_bijoe_schema
@@ -17,6 +17,7 @@ owner=montpellier3m
psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='$owner'" | grep -q 1 || psql -c "CREATE ROLE $owner;"
+psql -c "select pg_terminate_backend(pid) from pg_stat_activity where datname = '$destination';" >/dev/null
psql -c "DROP DATABASE IF EXISTS $destination;" >/dev/null
psql -c "CREATE DATABASE $destination WITH OWNER '$owner';" >/dev/null
pg_dump --no-owner --schema $schema $origin | psql $destination >/dev/null