I\'m writing my first Rails app. I\'ve run a few rails generate model ...
and rake db:migrate
commands, but I now want to change my data model and
NOTE: Use the suggestions with caution, it is very dangerous for non-dev environments.
If
rake db:migrate:status
gives you a migration that says
up 20120702151447 ********** NO FILE **********
Then the best thing to do would be to do a (note that the following command will drop the database):
rake db:reset
to redo all migrations. If the last migration is the one missing, then schema.rb
will have the last migration that rake db:migrate
will look for:
ActiveRecord::Schema.define(:version => 20120702151447) do
Change that number to the last one in your migrate folder.
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.
This is what worked for me. Combine the steps given in this answer and comment by dB.
rake db:migrate:status
****NO FILE****
entry, just note the version number as noFileVersion. Note the version of the entry just above no file entry(stable_version).noFileVersion_create_nothing.rb
, and body class CreateNothing < ActiveRecord::Migration
def change
end
end
rake db:migrate VERSION=stable_version
noFileVersion_create_nothing.rb
manually.rake db:migrate
.rake db:migrate:status
again to check if No file entry has disappeared.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