Updating the Play Framework with Heroku

I am using Play Framework (1.2.4). I created a UserAccount object, deployed it to Heroku. Excellent. Then I added the isAdmin field to the isAdmin class, deployed it locally, and it worked fine (but I use the built-in database), then I deployed it to Heroku, and now I get the following exception

 2011-12-23T09:03:35+00:00 app[web.1]: play.exceptions.JavaExecutionException: org.hibernate.exception.SQLGrammarException: could not load an entity: [models.UserAccount#2] 2011-12-23T09:03:35+00:00 app[web.1]: PersistenceException occured : org.hibernate.exception.SQLGrammarException: could not load an entity: [models.UserAccount#2] ... 2011-12-23T09:03:35+00:00 app[web.1]: Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not load an entity: [models.UserAccount#2] 2011-12-23T09:03:35+00:00 app[web.1]: Caused by: org.hibernate.exception.SQLGrammarException: could not load an entity: [models.UserAccount#2] 2011-12-23T09:03:35+00:00 app[web.1]: Caused by: org.postgresql.util.PSQLException: ERROR: column useraccoun0_.isadmin does not exist ... 

I searched around to figure out how to do database updates, and the Play website says that Hibernate should handle this for me.

Here are my database properties:

 %prod.db=${DATABASE_URL} %prod.jpa.dialect=org.hibernate.dialect.PostgreSQLDialect %prod.jpa.ddl=update 

What am I doing wrong? Thanks for the help.

+4
source share
3 answers

You need to run the evolution of the Play database on Heroku:

 heroku run "play evolutions:apply --%prod" 
+6
source

The jpa.ddl property should not be anywhere else in Prod mode. Updating is risky in production, as it can break the database (as you think, this happens to you!

The correct way to manage this would be:

  • Install the Heroku SQL console in your Heroku application (from here )
  • Change jpa.ddl to none
  • Connect to your heroku database using the SQL console and apply any patches / updates you have for
  • Download the application in Heroku (do not forget to make a new commit locally, or Heroku will say that the code is already updated)

That should work.

+7
source

Just notice, the instruction for heroku included db in its .gitignore, so if you use this:

heroku run "play evolution: apply -% prod"

You will receive an error / warning message. However, to my surprise (and delight), restarting the process really applied my evolutions and updated my db (checked using the heroku server console mentioned below :-)). It's a little mysterious how it worked, but happy that it was!

+1
source

Source: https://habr.com/ru/post/1387706/


All Articles