diff init20.gradle @ 192:4f8780714e4d

disconnect sessions prior to dropping database
author smith@nwoca.org
date Tue, 14 Apr 2015 16:41:45 +0100
parents 5b142b2b730f
children 0c0b1413ea70
line wrap: on
line diff
--- a/init20.gradle	Mon Apr 13 16:50:17 2015 +0100
+++ b/init20.gradle	Tue Apr 14 16:41:45 2015 +0100
@@ -291,6 +291,8 @@
                                 gradle.environmentDatabase.jdbc.password,
                                 driverName)
                         if (dropIt) {
+							logger.info "disconnecting sessions from $databaseName"
+							sql.execute "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$databaseName';"
                             logger.info "dropping $databaseName (if exists) from $adminUrl"
                             sql.execute 'DROP DATABASE IF EXISTS "' + databaseName + '";'
                         }