I cloned my project. Bundled with "bundle install", then run "rake db:migrate". I am getting this error: (when I run the rails server and open my browser to localhost:3000) "Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=development' to resolve this issue."
I checked all migrations one by one and all were executed without errors. Also no errors were shown after the execution of "rake db:migrate".
This is what I see when I execute "rake db:migrate:status"
I am on development environment. Please let me know if you need any other information.
I also tried "bundle exec rake db:migrate", and "bundle exec rake db:migrate:reset" as "burninggramma" suggested.
Any clues what causes the error?
Running
rake db:migrate RAILS_ENV=test
did it for meI'm guessing the error is that you are creating a table that already exists, I had this problem before. Step 1 look into the error when you rake dv:migrate
Step 2 go to the model where this table is created
Step 3 add drop_table :[YOUR TABLE] right before the create_table :[YOUR TABLE]
Step 2 run rake db:migrate
Step 3 remove the drop_table once the your migration is done
Two reasons 'db:migrate:reset' did not work for me
So What I tried is to update the 'scheema_migrations'(mysql) table with the list of migrations(just version values) that I was really sure were already run on my db(development), this can be lil time consuming process but it works. I would not attempt this on production though.
When I executed
rake test
and met bug :I tried and succeeded with:
List your executed migrations with
rake db:migrate:status
and look if every migration was executed. You can try to cancel your migration withrake db:abort_if_pending_migrations
and try to migrate again.1.
Maybe its default in ruby2/rails4 but have you tried:bundle exec rake db:migrate
?2.
Another option would be resetting the whole database - use with CAUTION! resets all the data as well -bundle exec rake db:migrate:reset
+)
I would just make sure that you are executing everything in the same development env: