changeset 201:e721a977726b

Revoke ability to connect to database before attempting to drop it for task database(Drop|Create)
author Christopher Springer <springer@nwoca.org>
date Fri, 21 Aug 2015 12:32:03 +0100
parents 8aab0c2c1259
children b217dc3b654a
files init20.gradle
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/init20.gradle	Fri Aug 14 16:13:24 2015 +0100
+++ b/init20.gradle	Fri Aug 21 12:32:03 2015 +0100
@@ -298,7 +298,9 @@
                                 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';"
+							sql.execute "REVOKE CONNECT ON DATABASE " + databaseName + " FROM public;"
+							sql.execute "REVOKE CONNECT ON DATABASE " + databaseName + " FROM " + gradle.environmentDatabase.jdbc.username + ";"
+							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 + '";'
                         }