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
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.
Run these commands in this order:
rake db:drop
rake db:create
rake db:migrate
rake db:seed
- This one is only necessary if you have seeded data.
just run rake db:migrate
then start server, see then what happens, looks like existing migrations are yet not part of schema. Or you schema_migrations table might be missing some version value.
尝试运行bundle exec rake db:migrate RAILS_ENV=development
为我运行的bundle exec rake db:migrate RAILS_ENV=development
仅运行bundle exec rake db:migrate
无法解决问题
As one of the comments above, utilizing the following works for me:
rake db:drop
rake db:create
rake db:migrate
when rake db:migrate
or restarting didn't help.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.