Mercurial > public > develkit
comparison 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 |
comparison
equal
deleted
inserted
replaced
191:5b142b2b730f | 192:4f8780714e4d |
---|---|
289 def sql = Sql.newInstance(adminUrl, | 289 def sql = Sql.newInstance(adminUrl, |
290 gradle.environmentDatabase.jdbc.username, | 290 gradle.environmentDatabase.jdbc.username, |
291 gradle.environmentDatabase.jdbc.password, | 291 gradle.environmentDatabase.jdbc.password, |
292 driverName) | 292 driverName) |
293 if (dropIt) { | 293 if (dropIt) { |
294 logger.info "disconnecting sessions from $databaseName" | |
295 sql.execute "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$databaseName';" | |
294 logger.info "dropping $databaseName (if exists) from $adminUrl" | 296 logger.info "dropping $databaseName (if exists) from $adminUrl" |
295 sql.execute 'DROP DATABASE IF EXISTS "' + databaseName + '";' | 297 sql.execute 'DROP DATABASE IF EXISTS "' + databaseName + '";' |
296 } | 298 } |
297 | 299 |
298 if (createIt) { | 300 if (createIt) { |