A migration is a script that changes the database structure: adds a column, a table or an index, changes a data type. The application and the database must agree – the new version of the code expects the new structure. Ship one without the other and the site goes down.
How it usually looks
A developer ships the new app version through an automated process, but runs the database change by hand – from their laptop, in a terminal, “just this once”. Sometimes they forget. Sometimes they run it against the wrong database. Sometimes the test and production databases have quietly drifted apart and nobody knows exactly why.
What you get when CI/CD runs migrations
- The same order everywhere. Every migration is a versioned file in the repository. Test, staging and production go through the same steps, in the same order.
- Test first, then production. The pipeline runs migrations against a copy of the database and runs the tests. If something breaks, it breaks in test, not in front of customers.
- Code and schema ship together. The new app version isn't released until the migration has succeeded.
- An audit trail. You know who changed what, when and why – through code review, like any other code.
- No personal access to production. Nobody needs the production database password on their laptop. Only the pipeline has access.
What to watch out for
- A backup before every migration – automatically, as a pipeline step.
- Changes that don't break the old version. Add the new column first, ship code that uses it, and only then drop the old one. That way you can roll back the app without taking the site down.
- Large tables. Adding an index to a table with millions of rows can lock the database. Such migrations are planned and run in a non-blocking way.
- A way back. For every migration you should know how to undo it – or why you won't, and will roll forward with a fix instead.
There are tools for almost every language and database – Flyway, Liquibase, Prisma, Drizzle, Alembic, Laravel migrations. The tool matters less than the rule: nobody changes the production database by hand.








