---
title: "Never edit an applied migration · Agent Wranglers"
url: https://agentwranglers.se/playbook/data/migrations/immutable-migrations
updated: 2026-10-20
licence: "All rights reserved"
---

# Never edit an applied migration

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Required
- Chapter: [Migrations](https://agentwranglers.se/playbook/data/migrations)
- Rule: Once a migration has run anywhere outside your own machine, never change it. Fix mistakes with a new migration.
- How: Many tools store a checksum of each applied file and refuse to run when it changes. Treat that error as a warning about history, not as something to switch off.
- Check: The migration tool's checksum validation is on. CI also fails when a pull request changes or deletes a migration file that exists on the main branch.

Example:

```sh
# CI step: prints nothing and passes when only new migrations were added
test -z "$(git diff --name-only --diff-filter=MDR origin/main...HEAD -- migrations/)"
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers data playbook: https://agentwranglers.se/playbook/data/migrations/immutable-migrations`.

- Previous: [Change the schema only with migrations](https://agentwranglers.se/playbook/data/migrations/versioned-migrations)
- Next: [Expand first and contract later](https://agentwranglers.se/playbook/data/migrations/expand-and-contract)
- [Migrations](https://agentwranglers.se/playbook/data/migrations)
