每次迁移后你需要重新启动Heroku吗? [英] Do you need to restart Heroku after every migration?
问题描述
heroku restart --app = app_name
我从来没有这样做过(我并不完全是老手,但我跑了在此之前有大量的迁移,并且从未必须重新启动heroku)。
每次迁移后,我是否需要重新启动heroku?或者,这是更多的情况下的事情?
如果您通过迁移更改您的数据库,那么您将需要在Heroku上重新启动应用程序。当Rails以生产模式启动时,它会缓存数据库模式。迁移运行在一个正在运行的Web进程不知道的进程中。因此,为了获取所需的更改,至少需要重新启动Web进程。如果您的应用程序在部署时闲置,并且您运行了迁移,它将在应用程序启动时接收新架构。
Recently I had an issue where my db scheme change wasn't being reflected on Heroku PG. I double checked to see that both migration and seed succeeded. What was even weirder was that the db scheme change worked fine on a staging heroku deployment (after the exact same migration/seed). After some searching around, I learned that you are supposed to restart heroku after migrations via:
heroku restart --app=app_name
I've never had to do this (I'm not exactly a veteran, but I've run a good amount of migrations before and have never had to restart heroku for this particular reason).
Do I actually need to be restarting heroku after each migration? Or is this more of a case by case thing?
If you make changes to your DB via migrations then you will need to restart the application on Heroku. When Rails starts in production mode it caches the DB schema. Migrations run in one off processes which the running web process is not aware of. So for it to pick up the changes you need to restart at least your web processes. If your application was idling when you deployed and you ran the migrations it would pick up the new schema as the app started.
这篇关于每次迁移后你需要重新启动Heroku吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!