mirror of
https://github.com/floci-io/floci.git
synced 2026-11-30 17:05:21 -05:00
fix(rds): restore a postgres snapshot on an image that creates a template database at startup (#7394)
* fix(rds): restore a postgres snapshot on an image that creates a template database at startup * test(rds): clean up the template restore test's instances and snapshot even when it fails * test(rds): build the template restore test's requests with RdsRequests
This commit is contained in:
1 parent
b9a22d55c8
commit
e02b91714d
3 files changed
+114
-6
No files matched your search
+5
-2
@@ -1293,11 +1293,14 @@ public class RdsContainerManager implements RdsBackendGate, RdsBackendEndpointRe
|
||||
set -e
|
||||
USER="$1"
|
||||
|
||||
# Terminate target connections (including pg_cron workers) when dropping databases
|
||||
# Drop every database but postgres, template0 and template1, including template
|
||||
# databases an image creates at startup (PostGIS's template_postgis), which the dump
|
||||
# creates again. Terminate target connections (including pg_cron workers).
|
||||
psql -v ON_ERROR_STOP=1 -U "$USER" -d postgres -tAc \\
|
||||
"SELECT datname FROM pg_database WHERE datistemplate = false AND datname <> 'postgres'" \\
|
||||
"SELECT datname FROM pg_database WHERE datname NOT IN ('postgres', 'template0', 'template1')" \\
|
||||
| while read -r db; do
|
||||
[ -z "$db" ] && continue
|
||||
psql -v ON_ERROR_STOP=1 -U "$USER" -d postgres -c "ALTER DATABASE \\"$db\\" IS_TEMPLATE false"
|
||||
psql -v ON_ERROR_STOP=1 -U "$USER" -d postgres -c "DROP DATABASE IF EXISTS \\"$db\\" WITH (FORCE)"
|
||||
done
|
||||
|
||||
|
||||
Reference in new issue
Block a user