Reversible migrations

A step of the Cloud application tree on Gradus, in the Build & ship area: Config, lint, releases, IaC.

Change the data in stages that keep the previous release working: expand, backfill, then contract in a later release, so a rollback never meets a schema it cannot read.

Usually comes after: One-command rollback.

Leads to: Blue-green releases.

Prompt for your AI assistant

Read the database decision record in docs/decisions and this service's migrations or data model. Write the expand and contract rule into docs/: a breaking change ships as an additive change, a release that handles both shapes, a backfill and a later release that removes the old shape. Where the database has migration files, add a CI check that fails on a destructive change in the same release as the code that stops using it. Then rename one real field this way, deploying after every stage and rolling back once to prove the previous release still works.

This is https://gradus.kazet.blog/tree/cloud-application/step/reversible-migrations as plain HTML. In a browser the page also lets you mark the step forged and copy a message for your AI assistant.