• Register
0 votes
112 views

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
6 5 3
6,930 points

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.

9 7 4
38,600 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

Schmena_migration:

  • 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.
11 5 1
3,890 points

Related questions

1 vote
1 answer 114 views
114 views
Problem: I am beginner to ruby on rails. Recently I have started learning ruby on rails in depth. I am trying to use the ruby on rails to develop my website but I am facing below error whenever I try to open the localhost. could not connect to server: Connection refused ... can’t fix the error so now I am looking for help from ruby on rails expert to give me the quick fix for above error.
asked May 18 Martin K 6.6k points
0 votes
2 answers 7 views