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?
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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With