comparison init20.gradle @ 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
comparison
equal deleted inserted replaced
200:8aab0c2c1259 201:e721a977726b
296 gradle.environmentDatabase.jdbc.username, 296 gradle.environmentDatabase.jdbc.username,
297 gradle.environmentDatabase.jdbc.password, 297 gradle.environmentDatabase.jdbc.password,
298 driverName) 298 driverName)
299 if (dropIt) { 299 if (dropIt) {
300 logger.info "disconnecting sessions from $databaseName" 300 logger.info "disconnecting sessions from $databaseName"
301 sql.execute "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$databaseName';" 301 sql.execute "REVOKE CONNECT ON DATABASE " + databaseName + " FROM public;"
302 sql.execute "REVOKE CONNECT ON DATABASE " + databaseName + " FROM " + gradle.environmentDatabase.jdbc.username + ";"
303 sql.execute "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '" + databaseName + "';"
302 logger.info "dropping $databaseName (if exists) from $adminUrl" 304 logger.info "dropping $databaseName (if exists) from $adminUrl"
303 sql.execute 'DROP DATABASE IF EXISTS "' + databaseName + '";' 305 sql.execute 'DROP DATABASE IF EXISTS "' + databaseName + '";'
304 } 306 }
305 307
306 if (createIt) { 308 if (createIt) {