Glossary

Database migration

A database migration is a versioned, scripted change to the structure of a database — adding a table, adding a column, changing a type, backfilling values. The scripts live in the repository with the code and run in order, so every environment reaches the same schema by the same path.

The alternative, changing schemas by hand, fails in a specific and expensive way: staging and production drift apart, nobody can say what production actually looks like, and a deployment succeeds everywhere except where it matters.

The rule that prevents most migration incidents is that a schema change and the code using it should be deployable independently. Add the column, deploy code that writes to both old and new, backfill, then remove the old — each step reversible on its own.

← Back to the glossary