Agent Wranglers

DAT-20Recommended

Change the schema only with migrations

Every schema change is a numbered migration file in version control. Nobody changes a shared database by hand.

How to do it

Use a migration tool, such as Flyway, Liquibase, Alembic, Prisma Migrate or the framework's own. Each file runs once, in order, and the database records which ran. The deploy runs pending migrations before the new code starts.

How to check

Build a fresh database from the migrations alone. Its schema matches production exactly, compared with a schema dump.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/data/migrations/versioned-migrations">Agent Wranglers data and databases playbook</a>. In code you write, add a comment next to it with the same link.