• Register
0 votes
197 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

Please log in or register to answer this question.

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 2
3,890 points

Related questions

0 votes
1 answer 7 views
7 views
Problem: t looks like I have a circular issue regarding Ruby over Rails migration procedure. I am following the online available article and now reached the point where I need to modify my very first table. I ran the following, [tims@web2 working_ror]# rails generate model ... was to drop and rebuild everything below. rake db: drop rake db: create rake db: distant and the conclusions are all same.
asked Dec 1, 2020 sasha 5.3k points
0 votes
1 answer 35 views
35 views
Problem: Hello Kodlogs, I tried pushing my app and I got an error message of this nature; you must use bundler 2 or greater with this lockfile. What can I do to correct this?
asked Nov 2, 2020 Festus James 360 points
0 votes
1 answer 5 views
5 views
Problem: Hello Kodlogs, I was working on an app I want to deploy for use within my business but I was faced with a hosting issue so I decided to fix it with Heroku using a custom domain and I got this error: installing doc 3.12.2 installing pg 0.15.1 an ... failed to install gems via bundler. ! ! detected sqlite3 gem which is not supported on heroku. ! ! push rejected, failed to compile ruby app
asked Jan 14 Festus James 360 points
1 vote
1 answer 318 views
318 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, 2020 Martin K 6.6k points
0 votes
1 answer 11 views
11 views
Problem: Hello Kodlogs, I encountered a strange issue where vagrant works fine for a while and it completely stops working unexpectedly. Afterward, any of the vagrant commands I run just give me this error: "exec error: exec: "ruby": executable file not found in %PATH%"
asked Dec 29, 2020 Festus James 360 points
0 votes
1 answer 16 views
16 views
Problem: Hello Kodlogs, I tried installing Ruby with rbenv. I used homebrew to install rbenv ~ $ brew install rbenv That process was successful. Then I proceeded to install the ruby version of 2.6.1 in rbenv but it kept hanging on the following line. ~ $ rbenv install 2.6. ... .tar.bz2 Installing ruby-2.6.1... ruby-build: use readline from homebrew I think it's stuck, can someone help me fix this?
asked Dec 29, 2020 Festus James 360 points
0 votes
1 answer 37 views
37 views
Problem: Hello Kodlogs, Playing my way around with this code contact_list = [ {"name" => "jack", "phone_number" => "6789"}, {"name" => "Tracy", "phone_number" => "2345"} ] contact_list.each do |contact| puts "Contact: #{contact_list["name"]} and ... : #{contact_list["phone_number"]}" end It returns: no implicit conversion of String into Integer (TypeError) How do I correct this I'm confused?
asked Nov 8, 2020 Festus James 360 points
0 votes
1 answer 30 views
30 views
Problem: I encountered the 'cannot load such file -- bcrypt_ext' error while running my rails command. What could be the problem and how can I solve it?
asked Oct 27, 2020 Festus James 360 points