Symptom observed twice (migrations 012 and 013): deploy-erosi.sh ran the migration loop's first iteration (the `CREATE TABLE IF NOT EXISTS _applied_migrations` step) then silently skipped every file in supabase/migrations/*.sql without printing a single skip/apply line. Had to `psql -f <new-migration>` by hand on ambrosio after every deploy. Root cause: the deploy uses `ssh host bash -s << 'REMOTE' ... REMOTE` so the outer bash on the remote reads its own script from stdin. Any `docker compose exec -T db psql ...` inside that script — particularly inside a command substitution like `already=$(docker compose exec -T ...)` — inherits that stdin and consumes it, eating the rest of the heredoc. Fix: pass `</dev/null` (or the migration file for the actual `apply` step) to every `docker compose exec -T` call so docker gets an empty / file-scoped stdin instead of the parent's heredoc. Verified on ambrosio: deploy now prints all 13 `skip ... (applied)` lines as expected, and will apply new migrations going forward without manual intervention. - CLAUDE.md: gotcha #20 documenting the pattern; applies to any heredoc-delivered remote script using `docker compose exec -T` or `kubectl exec`.
6.8 KiB
Executable File
6.8 KiB
Executable File