A database migration is a controlled change to your database structure — adding a table, renaming a column, or creating a relationship. Migrations track changes in files so you can apply them consistently across environments. For vibe coders, AI generates migrations when you modify your data model, but understanding them prevents data loss.
Migrations are version control for your database. Just like Git tracks code changes, migrations track database structure changes.
You can't just edit a database like a text file:
Migrations solve all of this.
| Operation | Example |
|---|---|
| Add table | Create a new products table |
| Add column | Add avatar_url to users |
| Remove column | Drop unused legacy_field |
| Add index | Speed up queries on email |
| Add relationship | Connect users to posts |
Always be careful with:
AI generates migrations automatically when you change your schema. Always: