0
0
Ruby on Railsframework~5 mins

Why migrations version the database in Ruby on Rails - Quick Recap

Choose your learning style9 modes available
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?
AA database table with migration versions
BA file in the app folder
CA log in the server console
DA config setting in routes.rb
Why are migration versions usually timestamps?
ATo match Ruby version numbers
BTo encrypt migration data
CTo store user IDs
DTo order migrations by creation time
What happens if you try to run a migration that is already versioned in the database?
ARails skips it
BRails runs it again
CRails deletes the database
DRails crashes
Which Rails command applies new migrations to the database?
Arails server
Brails generate migration
Crails db:migrate
Drails console
What is stored in the schema_migrations table?
AUser passwords
BMigration version timestamps
CApplication logs
DRoutes definitions
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.