Recall & Review
beginner
What is a migration in Rails?
A migration is a way to change the database schema over time in a consistent and easy way. It helps create, modify, or drop tables and columns.
Click to reveal answer
beginner
How do you generate a new migration file in Rails?
Use the command
rails generate migration MigrationName. This creates a new migration file with a timestamp.Click to reveal answer
beginner
What method do you use inside a migration to create a new table?
Use the
create_table method inside the change method to define a new table and its columns.Click to reveal answer
intermediate
What does the
change method do in a migration?The
change method defines the changes to apply to the database. Rails can automatically reverse these changes when rolling back.Click to reveal answer
beginner
How do you run migrations to update the database schema?
Run
rails db:migrate to apply all pending migrations and update the database schema.Click to reveal answer
Which command creates a new migration file in Rails?
✗ Incorrect
The correct command is
rails generate migration MigrationName to create a new migration file.What method inside a migration defines the database changes?
✗ Incorrect
The
change method defines the changes to apply in the migration.How do you apply migrations to update the database?
✗ Incorrect
Use
rails db:migrate to apply migrations and update the database schema.Which method creates a new table in a migration?
✗ Incorrect
The
create_table method is used to create a new table inside a migration.What does Rails use to order migration files?
✗ Incorrect
Rails orders migrations by the timestamp prefix in the filename to run them in the correct sequence.
Explain how to create and run a migration to add a new column to an existing table in Rails.
Think about the command to create migration, the method to add a column, and how to apply it.
You got /3 concepts.
Describe the purpose of the change method in Rails migrations and how it helps with rolling back changes.
Focus on how change method works both forward and backward.
You got /3 concepts.