Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does rake db:rollback rollback three steps?

Normally when I do

$ rake db:rollback 

it rolls back one migration. But now, repeatedly times, it has rollbacked 3 steps.

How come this behaviour?

I'm on Rails 3.2.13.

like image 217
Fellow Stranger Avatar asked Nov 06 '13 06:11

Fellow Stranger


People also ask

How rollback rails db Migrate?

To check for status, run rails db:migrate:status . Then you'll have a good view of the migrations you want to remove. Then, run rails db:rollback to revert the changes one by one. After doing so, you can check the status again to be fully confident.

Which command is used to rollback migration in Rails?

You must rollback the migration (for example with bin/rails db:rollback ), edit your migration, and then run bin/rails db:migrate to run the corrected version.

What does a migration rollback do?

rollback all means it will reset all migration. so if you change anything on migration file then it will recreate and affect it.


1 Answers

You can specify the number of steps like this:

rake db:rollback STEP=3 

The STEP parameter is actually an environment variable here. If, in your terminal, you run the command echo $STEP, does it return 3? If it does, you can execute export STEP=1 to get back to expected behaviour. If it happens again, try to find out where this environment variable is being set.

like image 131
Jaap Haagmans Avatar answered Oct 02 '22 12:10

Jaap Haagmans