rake db:rollback not working?
Solution 1:
Solution (see my comment): run
rake db:migrate:status
and correct problems you find there. In this case (per @MarkThomas' followup), you might want to check all files you need are in place.
Solution 2:
This is what worked for me. Combine the steps given in this answer and comment by dB.
- run
rake db:migrate:status
- If you have a
****NO FILE****
entry, just note the version number as noFileVersion. Note the version of the entry just above no file entry(stable_version). - created a "dummy" file with name
noFileVersion_create_nothing.rb
, and body
class CreateNothing < ActiveRecord::Migration[6.0]
def change
end
end
- run
rake db:migrate VERSION=stable_version
- remove the
noFileVersion_create_nothing.rb
manually. - run
rake db:migrate
. - run
rake db:migrate:status
again to check if No file entry has disappeared.
Solution 3:
The following worked for me:
rake db:migrate:down VERSION=20190304092208
Version number can be obtained by the following command:
rake db:migrate:status
This was the last version number to rollback one last migration