Programmers learn & share
0 votes

Problem :

I cloned my project and bundled it with "bundle install" after that tried to run it using  "rake db:migrate" but facing following error
migrations are pending. to resolve this issue, run: bin/rails db:migrate rails_env=development
by (6.9k points)   | 45 views

2 Answers

0 votes

Solution :

When one faces such issue one should just Open the database and click on schema_migration table. Then one can see migrations listed as below. enter image description here

Then you just need to Sort the version column and find the latest migration you want to go back to. Then you can Delete or Insert a new one. Rails always keeps all the migration history in this table, so you can adjust the migration history to your liking.

by (36.1k points)  
0 votes

This error can be solved in many ways because there many reasons behind this error;

Duplication of the table:

Always make sure that the table does not exist already. This can be done in the following steps;

  • Type- rails dbconsole
  • Type – tables (Check to see if there is an error during the rake db: migrate that has the table name like, create_table(: test) rake aborted!)
  • If you see the table name after running the .tables in the console type then drop table TABLENAME;
  • Then .quit to go back to branch again and run the rake db: migrate command again.
  • Another option of resetting the whole database  - use with caution! Reset all the data as well – bundle exec rake db:migrate: reset

For making sure you are running everything in the same development environment;

RAILS_ENV=development bundle exec rake db:migrate:reset

RAILS_ENV=development bundle exec rails s


  • Go to the database.
  • Click the schema_migration table. You can see the migration list;
  • Sort the versions columns and find the latest migrations if you want to go back.
  • Delete or insert the new one.
  • Rails can keep all the migration history in this table. So, you can adjust the migration history according to your requirement.
by (2.8k points)  
2,227 questions
2,734 answers
241 users