Once an app is live, its database keeps changing: a new column for delivery address, a new table for refunds, a rule that phone numbers must be unique. Teams never make these changes by hand on the live server, because one typo can break the app for everyone. They use migrations. Adverts we read also named ORMs and query tools such as Entity Framework, Hibernate and Prisma, so it helps to know what they are.
What a migration is
A migration is a small file that describes one change to the database, kept in Git alongside your code. Each file has a timestamp or number so they run in order:
migrations/
001_create_customers.sql
002_create_orders.sql
003_add_delivery_area.sqlThe third one might contain:
ALTER TABLE orders
ADD COLUMN delivery_area TEXT;A migration tool records which files have already run on each database. When you deploy, it runs only the new ones. Your laptop, your teammate's laptop and the live server all end up with the same structure.
Why this matters
- Repeatable: a new teammate can build the whole database from scratch with one command.
- Reviewable: database changes go through pull requests like any other code.