简体   繁体   English

Play Framework在生产模式下不适用Evolution

[英]Play Framework does not apply Evolutions in Production mode

I recently deployed my Play App to a Heroku-Server. 我最近将Play应用程序部署到了Heroku服务器。 Running the App in Production-Mode leads to the following Error for each db-table: 在生产模式下运行该应用程序会导致每个数据库表出现以下错误:

Caused by: javax.persistence.PersistenceException: Query threw SQLException:ERROR: relation "tablename" does not exist

Procfile 程序文件

web: target/universal/stage/bin/myApp -Dhttp.port=${PORT} -DapplyEvolutions.default=true -DapplyDownEvolutions.default=false -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=${DATABASE_URL}

I had the same issue deploying the app on another (non-heroku) server. 在将应用程序部署到另一台(非Heroku)服务器时,我遇到了同样的问题。 Solved it there by first running in dev-mode to apply the schema and then switch to production. 首先在开发人员模式下运行以应用架构,然后切换到生产环境,从而解决了该问题。

Is there a reason for having the -DapplyDownEvolutions.default=false in your Procfile command? 在Procfile命令中是否有-DapplyDownEvolutions.default=false的原因? I'm not sure how that might interact with the -DapplyEvolutions.default=true ...it might be worth trying without it. 我不确定如何与-DapplyEvolutions.default=true交互...如果没有它,可能值得尝试。

If that does not work, you could run the evolutions in a one-off process like so: 如果那不起作用,则可以像这样一次性执行演化:

$ heroku run bash
...
~$ ./target/universal/stage/bin/myApp -DapplyEvolutions.default=true -DapplyDownEvolutions.default=false -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=${DATABASE_URL}

Once that completes, you're other dynos should be good to go. 一旦完成,您就可以使用其他测功机。 However, this creates a period in which the app is deployed, and the evolutions have not been run. 但是,这将创建一个部署应用程序的时期,并且尚未运行演进。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM