Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails app error - ActiveRecord::PendingMigrationError Migrations are pending; run 'rake db:migrate RAILS_ENV=development' to resolve this issue

The database is created, tables are created, data are there.

But after I restarted the Rails application, I got this error. The app is using MySQL. What's the issue here?

Thank you in advance

like image 994
user984621 Avatar asked Dec 19 '25 23:12

user984621


1 Answers

Solution

Simply run

rake db:migrate

There are migrations that need to be ran before your server can start. Learn what migrations are and how they are used in Rails with this RailsGuide.

Run that rake db:migrate command any time you make a migration, or any time you create a new project. If you get an error saying that migrations are pending, this is the answer. Then try to start the server again.

Only if that doesn't work, try what is below.

If that doesn't work

Run these commands in this order:

  1. rake db:drop

  2. rake db:create

  3. rake db:migrate

  4. rake db:seed - This one is only necessary if you have seeded data.

Remember, when in doubt: restart the server!

like image 91
Matt C Avatar answered Dec 22 '25 13:12

Matt C



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!