File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,14 @@ if [ -z "${result}" ]; then
24
24
message=" Database " ${DB_NAME} " on host " ${DB_HOST} " does not exist."
25
25
echo " ${MYNAME} : INFO: ${message} "
26
26
else
27
+ message=" finding current owner of DB ${DB_NAME} "
28
+ echo " ${MYNAME} : ${message} "
29
+ db_owner=$( psql --host=${DB_HOST} --username=${DB_ROOTUSER} --command=' \list' | grep ${DB_NAME} | cut -d ' |' -f 2 | sed -e ' s/ *//' )
30
+ message=" Database owner is ${db_owner} "
31
+ echo " ${MYNAME} : INFO: ${message} "
32
+
27
33
echo " ${MYNAME} : deleting database ${DB_NAME} "
28
- result=$( psql --host=${DB_HOST} --dbname=postgres --username=${DB_USER } --command=" DROP DATABASE ${DB_NAME} ;" )
34
+ result=$( psql --host=${DB_HOST} --dbname=postgres --username=${db_owner } --command=" DROP DATABASE ${DB_NAME} ;" )
29
35
if [ " ${result} " != " DROP DATABASE" ]; then
30
36
message=" Drop database command failed: ${result} "
31
37
echo " ${MYNAME} : FATAL: ${message} "
You can’t perform that action at this time.
0 commit comments