Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting: "Migrations are pending; run 'bin/rake db:migrate RAILS_ENV=development' to resolve this issue." after cloning and migrating the project

Tags:

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?

like image 301
Stefanos.Ioannou Avatar asked Jan 23 '14 13:01

Stefanos.Ioannou


People also ask

How does Rails check for pending migrations?

Rails provides a method to check if any migration is pending. Listing relevant methods from ActiveRecord::MigrationContext class below. This piece of code raises an exception ActiveRecord::PendingMigrationError if any migration is pending. In the next section, we will see the logic used for needs_migration?

What does db Migrate do?

DB migration is moving data from one or more source platforms to another target database. There are several reasons for migrating from one database to another. For example, a business might want to save resources by switching to a cloud-based database.

How do I reset migration in Rails?

just use rake db:reset , that will drop your database (same as undoing all migrations) and reset to the last schema. UPDATE: a more correct approach will be using rake db:migrate:reset . That will drop the database, create it again and run all the migrations, instead of resetting to the latest schema.


1 Answers

Interesting. Did you run rake db:create? Assuming you are using sqlite3, do this:

      rm -f db/*.sqlite3       rake db:create       RAILS_ENV=development bundle exec rake db:migrate       rails s -e development 

Also, can you list the contents of your config/database.yml file?

Edit: Warning! Obviously, you will lose your existing data.

like image 105
lewstherin Avatar answered Sep 28 '22 03:09

lewstherin