0
0
Ruby on Railsframework~5 mins

Running and rolling back migrations in Ruby on Rails - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What command runs all pending migrations in Rails?
Use rails db:migrate to run all migrations that have not yet been applied to the database.
Click to reveal answer
beginner
How do you rollback the last migration in Rails?
Use rails db:rollback to undo the last migration that was run.
Click to reveal answer
beginner
What does rails db:migrate:status show?
It shows a list of all migrations and whether each one has been applied (up) or not (down).
Click to reveal answer
intermediate
How can you rollback multiple migrations at once?
Use rails db:rollback STEP=n where n is the number of migrations to undo.
Click to reveal answer
intermediate
What is the difference between rails db:rollback and rails db:migrate:down VERSION=xxxx?
rails db:rollback undoes the last migration by default, while rails db:migrate:down VERSION=xxxx rolls back a specific migration by its version number.
Click to reveal answer
Which command runs all pending migrations in Rails?
Arails db:migrate
Brails db:rollback
Crails db:migrate:status
Drails db:seed
How do you undo the last migration in Rails?
Arails db:migrate
Brails db:reset
Crails db:rollback
Drails db:seed
What does rails db:migrate:status display?
ACurrent Rails version
BDatabase schema version
CList of seeds applied
DList of migrations and their applied status
How to rollback the last 3 migrations?
Arails db:rollback STEP=3
Brails db:migrate STEP=3
Crails db:rollback 3
Drails db:migrate:down STEP=3
Which command rolls back a specific migration by version?
Arails db:rollback STEP=1
Brails db:migrate:down VERSION=xxxx
Crails db:migrate:up VERSION=xxxx
Drails db:reset
Explain how to run migrations and then undo the last migration in Rails.
Think about commands to apply changes and then reverse the last change.
You got /4 concepts.
    Describe how to check migration status and rollback multiple migrations in Rails.
    Consider commands that show migration states and undo several steps.
    You got /4 concepts.