[英]How does rake db:migrate work on Heroku?
My app just crashed after I pushed to Heroku and ran rake db:migrate
. 我推送到Heroku并运行
rake db:migrate
之后,我的应用程序崩溃了。 But the error didn't make sense... 但是错误没有道理...
ActionView::Template::Error (undefined method `email_address' for #<Invite:0x000000065fb788>):
...because the migration contained: ...因为迁移包含:
rename_column :invites, :email, :email_address
So I eventually figured out that it worked after an app restart ( heroku restart
). 因此,我最终发现它在应用程序重启(
heroku restart
)后可以工作。 Good deal. 很好
However, I'm confused about how rake db:migrate
works now. 但是,我对
rake db:migrate
现在的工作方式感到困惑。 Every single other migration picked up the corresponding model attribute without the restart. 其他每一次迁移都将获取相应的模型属性,而无需重新启动。
What happens when I run rake db:migrate
on Heroku? 在Heroku上运行
rake db:migrate
时会发生什么? What spurs the app to pickup the new model attributes and why didn't it work this time? 是什么促使应用获取新的模型属性,为什么这次不起作用?
In a new rails app you can see the following 在新的Rails应用中,您可以看到以下内容
.../config/environments/development.rb ... /配置/环境/development.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
.../config/environments/production.rb ... /配置/环境/production.rb
# Code is not reloaded between requests
config.cache_classes = true
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.