migration.apply_failed
Applying the project's migrations to a database stopped at a step that failed.
Area 14, Tools; not declinable; the next step is usually the human's.
Why Jadpo refuses it
jadpo migrate apply runs each pending migration in a transaction of
its own, as a deploy step. When a step fails, because the database
can't be reached, PostgreSQL refuses a statement, or a backfill stops at
a record, that step is rolled back and nothing after it runs. The
migrations before it stay applied, as does every batch of a backfill
that committed, and the next run carries on from there, so a failed run
never leaves a migration half done.
Jadpo won't skip the step or carry on without it: the migrations after it, and the code you deploy, are written for the schema it makes. What stopped it is a database, an address or data only you can put right.
What it looks like
A project with one migration, whose DATABASE_URL, the variable the
connection's setting reads, names a database whose server isn't
running:
DATABASE_URL=postgresql://localhost:5499/notes jadpo migrate apply error Migrating main failed
- reason
- The database can't be reached. The step that failed was rolled back; the migrations before it stay applied, as does every batch of a backfill that committed, and the next run carries on from there.
- next
- Fix what stopped it, then run
jadpo migrate applyagain (human) - rule
- migration.
apply_ failed - help
- https://jadpo.
dev/docs/errors/migration. apply_ failed
(human) at the end of the next: line tells your coding agent to stop
and ask you which fix you want, because the choice is yours to make: it
decides which database the migrations go into, and whether it is ready
for them.
The same error names the migration and the field when the step that
failed is a backfill: one that stopped at a record, or stored values a
changed type no longer reads, each with what to change before applying
again. jadpo seed applies pending migrations before it runs, and
stops with this error when one fails.
How to fix it
The question is what stopped the step, which the reason: line says.
If the database's server isn't running, start it, then apply again:
jadpo migrate applyThe step that failed runs again, then every migration after it.
If the address is wrong, give the connection's setting the right
one, on this machine with jadpo config set, or in the environment of
the deploy:
jadpo config set database_urljadpo migrate apply reads the address from the environment, then
.env.local, and applies the pending migrations there.
Related
Markdown for agents: /docs/errors/migration.apply_failed.md.Built from Jadpo main at aee2e8f.