Recall & Review
beginner
What is the main purpose of versioning migrations in Rails?
Versioning migrations helps Rails keep track of which database changes have been applied, ensuring the database schema matches the code.
Click to reveal answer
beginner
How does Rails know which migrations to run when you update your app?
Rails compares the versions of migrations stored in the database with the migration files in the code to run only new migrations.
Click to reveal answer
intermediate
Why is it important to have a consistent migration version history across different environments?
Consistent migration versions ensure all environments (development, test, production) have the same database structure, avoiding errors.
Click to reveal answer
intermediate
What could happen if migrations were not versioned in Rails?
Without versioning, Rails wouldn't know which changes were applied, leading to possible duplicate changes or missing updates in the database.
Click to reveal answer
beginner
How does Rails store migration versions internally?
Rails stores migration versions as timestamps in a special database table called schema_migrations.
Click to reveal answer
What does Rails use to track which migrations have been applied?
✗ Incorrect
Rails uses a special table called schema_migrations to store migration versions.
Why are migration versions usually timestamps?
✗ Incorrect
Timestamps help Rails run migrations in the order they were created.
What happens if you try to run a migration that is already versioned in the database?
✗ Incorrect
Rails skips migrations that have already been applied to avoid duplicate changes.
Which Rails command applies new migrations to the database?
✗ Incorrect
The command rails db:migrate runs new migrations and updates the database schema.
What is stored in the schema_migrations table?
✗ Incorrect
The schema_migrations table stores the timestamps of applied migrations.
Explain why Rails uses versioning for database migrations and how it helps manage database changes.
Think about how Rails knows what changes are already done.
You got /4 concepts.
Describe what could go wrong if migration versions were not tracked in a Rails application.
Consider the risks of losing track of database updates.
You got /4 concepts.