Migrations — Changing Your Database Without Losing Data
Learn what database migrations are, how they work, and the safe patterns for evolving your schema in production.
Your app is live. Real users have real data in your database. Now you need to add a new feature that requires a new column. Or rename a table. Or change a column type.
You can't just drop the table and recreate it — there's data in there. You can't manually run SQL on production and hope you remember what you did — that's how you get environments that are subtly different and impossible to debug.
Migrations solve this. They're versioned, trackable, reversible scripts that evolve your database schema over time.
What Is a Migration?
A migration is a file that describes a change to your database schema. Each migration has:
- A version number or timestamp so they run in order
- An up function that applies the change
- A down function that reverses it
-- MigratiThis lesson is part of the Guild Member curriculum. Plans start at $29/mo.
