Skip to content

Glossary

Laravel migrations: database changes as versioned code

A versioned description of a change to the database structure that can be applied repeatably.

A database changes constantly over the life of a project. A new column, an extra table, an index, a rename. Apply changes like these by hand on every system and development, test and production drift apart sooner or later. And then nobody knows which state applies where.

A migration is a small file describing exactly one change step, along with the way back. It sits in the same repository as the code and is versioned with it. One command applies every step not yet applied, in the right order.

Why this matters more than it sounds

The real value is in being able to trace things. Any environment state can be reproduced from the repository. A new developer has a working database after two commands. A deployment brings the matching structural changes with it by itself.

One rule has proved itself. A migration that has already run on the production system is not changed again. Whatever is still missing follows as a new migration. Otherwise the states stop matching.

FAQ

Häufige Fragen

How is this different from migrating a whole application?
The word gets used for two things. Here it means individual change steps to the database structure. Moving a complete application to a new version or a new platform is something else and is under migration and upgrades.

Related

Terms that belong with this one

A project, or a question?

Write and tell us what it is about. You get an assessment from somebody who works with Laravel themselves, not from a sales desk.