Recall & Review
beginner
What is the purpose of the
db/migrate folder in a Rails project?The
db/migrate folder stores migration files that describe changes to the database schema, like creating or modifying tables. These files help Rails track and apply database changes in order.Click to reveal answer
beginner
What command do you run to create a new migration in Rails?
You run
rails generate migration MigrationName to create a new migration file with a timestamp in the db/migrate folder.Click to reveal answer
intermediate
How do migrations help keep the database schema consistent across different environments?
Migrations record each change as a file with a timestamp. Running
rails db:migrate applies all pending migrations in order, ensuring all environments have the same database structure.Click to reveal answer
intermediate
What is the role of the
schema.rb file in Rails?The
schema.rb file is a snapshot of the current database structure. It is updated after migrations run and helps Rails recreate the database schema quickly without running all migrations.Click to reveal answer
intermediate
What happens if you try to run
rails db:migrate but some migrations have already been applied?Rails checks which migrations have been applied by looking at the
schema_migrations table. It only runs new migrations that haven't been applied yet, so it avoids repeating changes.Click to reveal answer
Where are Rails migration files stored?
✗ Incorrect
Migration files live in the db/migrate folder to organize database schema changes.
What command creates a new migration file?
✗ Incorrect
Use rails generate migration followed by the name to create a migration file.
What does
rails db:migrate do?✗ Incorrect
It applies all migrations that have not yet been run to update the database.
What file shows the current database schema snapshot?
✗ Incorrect
schema.rb reflects the current structure of the database after migrations.
How does Rails know which migrations have already run?
✗ Incorrect
Rails tracks applied migrations in the schema_migrations table to avoid rerunning them.
Explain the purpose of the
db/migrate folder and how migrations work in Rails.Think about how Rails tracks and applies database changes step-by-step.
You got /4 concepts.
Describe the role of the
schema.rb file and how it relates to migrations.Consider how Rails can rebuild the database structure without running all migrations again.
You got /3 concepts.