Unverified Commit 7ffce9b3 authored by Julien Bouquillon's avatar Julien Bouquillon 🐫 Committed by GitHub
Browse files

fix(azure-db): fix drop (#877)

* fix(azure-db): fix drop

* fix test

* fix: handle weird db names
parent c4df0763
......@@ -38,17 +38,17 @@ echo
echo "deleting database ${DROP_DATABASE} on ${PGHOST}"
psql -abe "$PG_URL_ADMIN" <<EOF
SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE;
DROP DATABASE $DROP_DATABASE;
DROP DATABASE "$DROP_DATABASE";
EOF
echo
echo "deleting user ${DROP_USER_BASE} on ${PGHOST}"
psql -abe "$PG_URL_ADMIN" <<EOF
SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE;
REVOKE ALL PRIVILEGES ON SCHEMA public FROM \"${DROP_USER_BASE}\";
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM \"${DROP_USER_BASE}\";
REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM \"${DROP_USER_BASE}\";
REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM \"${DROP_USER_BASE}\";
DROP OWNED BY ${DROP_USER_BASE} CASCADE;
DROP USER ${DROP_USER_BASE};
REVOKE ALL PRIVILEGES ON SCHEMA public FROM "$DROP_USER_BASE";
REVOKE ALL PRIVILEGES ON ALL TABLES IN SCHEMA public FROM "$DROP_USER_BASE";
REVOKE ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public FROM "$DROP_USER_BASE";
REVOKE ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA public FROM "$DROP_USER_BASE";
DROP OWNED BY "${DROP_USER_BASE}" CASCADE;
DROP USER "${DROP_USER_BASE}";
EOF
......@@ -38,6 +38,10 @@ teardown_file() {
assert_line --partial 'SET SESSION CHARACTERISTICS AS TRANSACTION READ WRITE;'
assert_line --partial 'SELECT pg_terminate_backend (pg_stat_activity.pid)'
assert_line --partial 'deleting database autodevops_'${ID}' on localhost'
assert_line --partial 'deleting user user_'${ID}' on localhost'
assert_line 'DROP DATABASE'
assert_line 'DROP OWNED'
assert_line 'DROP ROLE'
assert_success
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment