dbmate status: Pending Migrations in CI
dbmate status prints each migration marked [X] applied or [ ] pending, and can exit non-zero when migrations are pending.
status is the read-only check for dbmate. Its --exit-code flag makes it directly usable as a pipeline gate.
What it does
dbmate status lists every migration with [X] for applied and [ ] for pending, then a summary count. With --exit-code it returns a non-zero status when any migration is pending, which a CI job can branch on.
Common usage
export DATABASE_URL="postgres://ci:$DB_PASSWORD@db:5432/app?sslmode=disable"
dbmate status
# fail the step if anything is pending
dbmate status --exit-codeOptions
| Flag | What it does |
|---|---|
| --exit-code | Exit non-zero if there are pending migrations |
| -d, --migrations-dir <dir> | Directory of migration files |
| -e, --env <name> | Env var holding the connection URL |
In CI
Use dbmate status --exit-code in a check job to fail when migrations were added but not applied, or to confirm a deploy left nothing pending. It is read-only, so it needs only connect access. Pair it with dbmate migrate in the deploy job.
Common errors in CI
"unable to connect to database" means DATABASE_URL or the network is wrong. If status shows migrations as pending that you expect to be applied, the runner is pointed at a different database or the migrations-dir differs from the deploy job. A missing schema_migrations table shows everything as pending, expected on a fresh database.