mirror of
https://github.com/block/buzz.git
synced 2026-11-03 16:01:35 +00:00
0002_backfill_default_community.sql is a psql operator script (\set, \ir, :'var' interpolation) but lived in migrations/, which sqlx::migrate! embeds wholesale. sqlx cannot run psql meta-commands, so every fresh deploy broke: BUZZ_AUTO_MIGRATE=true exited the relay with 'syntax error at or near "\"', buzz-admin migrate (the just setup path) failed identically with exit 5, and both left a wedged half-migrated DB. This also reddened the buzz-db unit test embedded_migrator_contains_consolidated_initial_schema (asserts exactly the consolidated 0001), which CI never ran. The module doc and that test already declare the intended invariant: the embedded migrator is the consolidated 0001 only; cutover/backfill is a separate operator script, not startup migration state. Restore it by relocating the script to scripts/cutover/1321_backfill_default_community.sql (dropping the 0002_ prefix so it never reads as sqlx state again), switching its schema include from \i to \ir so it resolves relative to the script rather than the operator's cwd, and adding scripts/cutover/README.md as the operator runbook. Wire the pure (infra-free) buzz-db tests into the unit path so this class of regression can't hide again. CI installs nextest, so just test-unit takes the nextest branch and bypasses run-tests.sh entirely — patch BOTH paths. Verified locally on a pristine Postgres: buzz-admin migrate -> exit 0, one migration row (v1); relay with BUZZ_AUTO_MIGRATE=true -> migrations complete, readiness 200, 36 tables, no wedge. buzz-db --lib goes from RED (left:2 right:1) to green. The relocated script's \ir resolves 0001 from a non-repo cwd. Co-authored-by: Tyler Longwell <tlongwell@block.xyz> Signed-off-by: Tyler Longwell <tlongwell@block.xyz>