Ruby-on-rails – How to rollback just one step using rake db:migrate

dbmigraterakeruby-on-rails

After adding migration files in the db/migrate folder and running rake db:migrate, I want get back to the previous step, I think using VERSION=n is the right way to do that, but I don't know the correct value of n to use. Is there any command to check the current n value?

It would be great if anyone could provide full instructions on how to use rake db:migrate.

Best Answer

For starters

rake db:rollback will get you back one step

then

rake db:rollback STEP=n

Will roll you back n migrations where n is the number of recent migrations you want to rollback.

More references here.