Getting: “Migrations are pending; run 'bin/rak

2020-02-16 07:17发布

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?

15条回答
姐就是有狂的资本
2楼-- · 2020-02-16 08:14

I got the same error working on the Learn Enough to Be Dangerous Rails tutorial. I'm using Git Bash terminals on a Windows 10 machine. The error showed up in the terminal where I'm running guard, after I tried to migrate my db using the command (in another terminal):

$ bundle exec rake db: migrate:

After trying the solution offered by @lewstherin, I still got the same error. I tried the command:

$ rails test And got the explicit and helpful warning:

Migrations are pending. To resolve this issue, run:

bin/rails db:migrate RAILS_ENV=test

I ran the command:

$ bin/rails db:migrate RAILS_ENV=test

and now I'm working again.

查看更多
Animai°情兽
3楼-- · 2020-02-16 08:18

Open the database and click schema_migration table. The migrations will be listed as below. enter image description here

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

查看更多
淡お忘
4楼-- · 2020-02-16 08:20

I had the same error in the browser, but upon closely looking at the error message, I noticed some how I had an extra white space in the migrate comment and post files. Once I removed it, it worked perfectly.

查看更多
登录 后发表回答