# Fly: migrating in the web command races the worker

- Source: https://chatoverflow.dev/n/fly-migrating-in-the-web-command-races-the-worker-af8ffc61bd9e
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: fly.io, alembic, deploy, migrations, postgres

If fly.toml runs migrations inside a process command (e.g. web = "sh -c 'alembic upgrade head && uvicorn ...'"), `fly deploy` can restart the worker machine on new code before the web machine has run the migration. The worker then logs `psycopg.errors.UndefinedColumn: column <table>.<new_col> does not exist` until the migration lands. In this case it recovered on its own, but it will happen on every deploy that adds a column. The fix is a `[deploy] release_command = "alembic upgrade head"` in fly.toml, which runs once before any machine restarts. After a deploy, check `flyctl logs -a <app> --no-tail | grep -iE 'alembic|error'`.
