diff --git a/CHANGELOG.md b/CHANGELOG.md index c0191bc..f819caf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- [#60] Force drop database when removing service accounts + - prevents errors if database is still in use ## [v14.18-1] - 2025-08-12 - [#46] Update postgresql to 14.18 diff --git a/resources/remove-sa.sh b/resources/remove-sa.sh index c326841..4c47310 100755 --- a/resources/remove-sa.sh +++ b/resources/remove-sa.sh @@ -17,6 +17,6 @@ SELECT_DB_NAMES="SELECT datname FROM pg_database WHERE datistemplate=false AND d for database_name in $(psql -U "${ADMIN_USERNAME}" -t -c "${SELECT_DB_NAMES}") do echo "Deleting service account '${database_name}'" - psql -U "${ADMIN_USERNAME}" -c "DROP DATABASE if exists ${database_name};" >/dev/null 2>&1 + psql -U "${ADMIN_USERNAME}" -c "DROP DATABASE if exists ${database_name} WITH (FORCE);" >/dev/null 2>&1 psql -U "${ADMIN_USERNAME}" -c "DROP USER if exists ${database_name};" >/dev/null 2>&1 done