Rails应用程序错误-ActiveRecord :: PendingMigrationError迁移正在等待;运行"rake db:migrate RAILS_ENV = development"来解决此问题 [英] Rails app error - ActiveRecord::PendingMigrationError Migrations are pending; run 'rake db:migrate RAILS_ENV=development' to resolve this issue

查看:166
本文介绍了Rails应用程序错误-ActiveRecord :: PendingMigrationError迁移正在等待;运行"rake db:migrate RAILS_ENV = development"来解决此问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

数据库已创建,表已创建,数据已存在.

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

但是在重新启动Rails应用程序之后,出现了此错误.该应用程序正在使用MySQL. 这是什么问题?

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

提前谢谢

推荐答案

解决方案

只需运行

rake db:migrate

必须先运行一些迁移,然后才能启动服务器.通过此RailsGuide 了解什么是迁移以及它们如何在Rails中.

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.

在进行迁移或创建新项目时,都运行rake db:migrate命令.如果您收到一条错误消息,说迁移正在进行中,这就是答案.然后尝试重新启动服务器.

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:

  1. rake db:drop

rake db:create

rake db:migrate

rake db:seed-仅当您已播种数据时,才需要此.

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

这篇关于Rails应用程序错误-ActiveRecord :: PendingMigrationError迁移正在等待;运行"rake db:migrate RAILS_ENV = development"来解决此问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆