fix: restore-db.sh connects as the container's Coolify superuser, not "postgres" #71

Merged
dan-claude-bot merged 1 commit from fix/restore-db-superuser into main 2026-07-16 10:22:17 +00:00
dan-claude-bot commented 2026-07-15 21:03:11 +00:00 (Migrated from github.com)

What

restore-db.sh hardcoded psql -U postgres. Coolify provisions each Postgres resource with a random POSTGRES_USER, so the postgres role doesn't exist and the restore dies with FATAL: role "postgres" does not exist.

Fix: expand $POSTGRES_USER inside the container (single-quoted sh -c), so the restore connects as the resource's own superuser. No credential is hardcoded; works for any Coolify Postgres.

How found

The Task 9 restore drill against box B — the first probe (psql -U postgres) failed exactly this way. See heavy-duty/infra#25.

Verify

  • bash -n + shellcheck clean.
  • Dry-expansion of the remote command:
    docker exec -i <container> sh -c 'psql -U "$POSTGRES_USER" -d <db> -v ON_ERROR_STOP=1'
    
    $POSTGRES_USER stays literal client-side and expands in-container; <db> expands client-side (unchanged behavior).

🤖 Generated with Claude Code

## What `restore-db.sh` hardcoded `psql -U postgres`. Coolify provisions each Postgres resource with a **random** `POSTGRES_USER`, so the `postgres` role doesn't exist and the restore dies with `FATAL: role "postgres" does not exist`. Fix: expand `$POSTGRES_USER` **inside** the container (single-quoted `sh -c`), so the restore connects as the resource's own superuser. No credential is hardcoded; works for any Coolify Postgres. ## How found The **Task 9 restore drill** against box B — the first probe (`psql -U postgres`) failed exactly this way. See heavy-duty/infra#25. ## Verify - `bash -n` + `shellcheck` clean. - Dry-expansion of the remote command: ``` docker exec -i <container> sh -c 'psql -U "$POSTGRES_USER" -d <db> -v ON_ERROR_STOP=1' ``` `$POSTGRES_USER` stays literal client-side and expands in-container; `<db>` expands client-side (unchanged behavior). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: heavy-duty/cast#71
No description provided.