Skip to content

Commit f2abb41

Browse files
jmschneiderclaude
andcommitted
clone/drop-database: forward admin URL's dbname as MAINTENANCE_DATABASE
DigitalOcean managed Postgres (and other managed services) don't expose a `postgres` maintenance DB. The admin URL the consumer provides is already proven to connect to *some* working DB (its path component), so forward that as MAINTENANCE_DATABASE rather than relying on the hardcoded `postgres` default in clone.sh / drop.sh. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent c3d7aa8 commit f2abb41

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

.github/actions/clone-database/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,11 @@ runs:
185185
printf 'PGUSER=%s\n' "$KP_DB_USER"
186186
printf 'PGPASSWORD=%s\n' "$KP_DB_PASSWORD"
187187
[ -n "${KP_DB_SSLMODE:-}" ] && printf 'PGSSLMODE=%s\n' "$KP_DB_SSLMODE"
188+
# Use the dbname from the admin URL as the maintenance DB.
189+
# Managed services (e.g. DigitalOcean = `defaultdb`) often
190+
# don't expose a `postgres` DB at all, but the admin URL is
191+
# already proven to connect to *some* working DB.
192+
[ -n "${KP_DB_DBNAME:-}" ] && printf 'MAINTENANCE_DATABASE=%s\n' "$KP_DB_DBNAME"
188193
printf 'SOURCE_DATABASE=%s\n' "$src"
189194
printf 'TARGET_DATABASE=%s\n' "$tgt"
190195
} > "$local_env"

.github/actions/drop-database/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ runs:
148148
printf 'PGUSER=%s\n' "$KP_DB_USER"
149149
printf 'PGPASSWORD=%s\n' "$KP_DB_PASSWORD"
150150
[ -n "${KP_DB_SSLMODE:-}" ] && printf 'PGSSLMODE=%s\n' "$KP_DB_SSLMODE"
151+
# See clone action for why we forward the admin URL's dbname.
152+
[ -n "${KP_DB_DBNAME:-}" ] && printf 'MAINTENANCE_DATABASE=%s\n' "$KP_DB_DBNAME"
151153
printf 'TARGET_DATABASE=%s\n' "$tgt"
152154
} > "$local_env"
153155
;;

0 commit comments

Comments
 (0)