From 3d85d0a50e5348a65407d5bfe4385e2b708a4f15 Mon Sep 17 00:00:00 2001 From: Oier Bravo Urtasun Date: Wed, 15 Apr 2026 00:31:00 +0200 Subject: [PATCH] fix(deploy): stop `docker compose exec -T` from draining the heredoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ` 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 ` ` inside that script — especially inside a command substitution like `x=$(docker compose exec -T db psql -c '...')` — inherits and consumes that same stdin, swallowing the rest of the heredoc. Symptom: the first iteration of a loop runs, every following iteration is silently skipped. Caused `infra/scripts/deploy-erosi.sh` to silently skip migrations 012 and 013 on prod until fixed (had to apply manually after every deploy). **Fix:** redirect stdin per call with `