Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Framework DB upgrades with Heroku

I'm using the Play Framework (1.2.4) I created a UserAccount object, deployed it to Heroku. Worked great. Then I added an isAdmin field to the UserAccount class, deployed it locally and it worked fine (but I'm using the in-memory DB), then I deployed it on Heroku and now I'm getting 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've searched around to figure out how to do DB upgrades and the Play website says that Hibernate should be handling that for me.

Here are my DB 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.

like image 243
Joel Avatar asked Dec 09 '22 03:12

Joel


1 Answers

The property jpa.ddl should be none when in Prod mode. Update is risky in production as it may break the DB (as it seems it's happening to you!

The proper way to manage this would be:

  1. Install Heroku SQL console on your Heroku app (from here)
  2. Change jpa.ddl to none
  3. Connect to your heroku database using the SQL console and apply any fixes/updates you have to
  4. Reupload the app to Heroku (remember to do a new commit locally or Heroku will say the code is already up to date)

This should work.

like image 138
Pere Villega Avatar answered Dec 11 '22 15:12

Pere Villega