Overview - Running and rolling back migrations
What is it?
Running and rolling back migrations in Rails means applying or undoing changes to the database structure. Migrations are like step-by-step instructions that tell Rails how to create, change, or remove tables and columns. Running a migration updates the database to a new state, while rolling back reverses those changes to a previous state. This helps keep the database in sync with the application code.
Why it matters
Without migrations, managing database changes would be manual, error-prone, and hard to track, especially when working with a team. Migrations let you safely evolve your database structure over time and easily undo mistakes. This keeps your app stable and your data safe as it grows and changes.
Where it fits
Before learning migrations, you should understand basic Ruby and Rails models. After mastering migrations, you can learn about database seeding, schema design, and advanced database features like indexes and constraints.