Destructive scripts
Goal
Migrations can mark scripts that destroy data, so that mitch asks for confirmation or an explicit switch before running them. Example: a down script with DROP TABLE users is convenient in development and fatal in production. The marking distinguishes the up script, the down script, or both.
Why
Reverts happen implicitly in several places: down, drop, redeploys of modified migrations, checkout, stash, and the planned rebuild of dependants. Today nothing stops any of them from dropping a table with data.
Already settled
- Whether a migration can be reverted at all follows from whether it has a down script; an empty down script is a revertible no-op. There is no separate
revertableflag. - Rebuilding dependants refuses to proceed when a dependant cannot be reverted safely, and is meant to refuse destructive down scripts once they can be marked: ADR
runner/rebuild-dependants-through-the-migration-graph. - Whether protection depends on the deployment (for example only on production) is open and connects to Deployments.