Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play 2.0 scala tutorial - heroku failing due to evolution

I'm following the Play 2.0 tutorial for Scala

Everything works fine until I try to push and run it on Heroku. after running "git push heroku master", the server crashes. Checking the logs, I see the following:

Starting process with command `target/start -Dhttp.port=37849 -Xmx384m -Xss512k -XX:+UseCompressedOops`
2012-08-13T06:52:45+00:00 app[web.1]: Play server process ID is 2
2012-08-13T06:52:46+00:00 app[web.1]: [info] play - database [default] connected at jdbc:h2:mem:play
2012-08-13T06:52:46+00:00 app[web.1]: [warn] play - Your production database [default] needs evolutions! 
2012-08-13T06:52:46+00:00 app[web.1]: 
2012-08-13T06:52:46+00:00 app[web.1]: CREATE SEQUENCE task_id_seq;
2012-08-13T06:52:46+00:00 app[web.1]: label varchar(255)
2012-08-13T06:52:46+00:00 app[web.1]: CREATE TABLE task (
2012-08-13T06:52:46+00:00 app[web.1]: id integer NOT NULL DEFAULT nextval('task_id_seq'),
2012-08-13T06:52:46+00:00 app[web.1]: );
2012-08-13T06:52:46+00:00 app[web.1]: 
2012-08-13T06:52:46+00:00 app[web.1]: # --- Rev:1,Ups - c5e3eee
2012-08-13T06:52:46+00:00 app[web.1]: [warn] play - Run with -DapplyEvolutions.default=true if you want to run them automatically (be careful)
2012-08-13T06:52:46+00:00 app[web.1]: Oops, cannot start the server.
2012-08-13T06:52:46+00:00 app[web.1]: PlayException: Database 'default' needs evolution! [An SQL script need to be run on your database.]
2012-08-13T06:52:46+00:00 app[web.1]:   at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.scala:422)

Any thoughts?

like image 525
user1594608 Avatar asked Aug 13 '12 07:08

user1594608


2 Answers

Either if you use the embed DB or the PostgreSQL, Play doesn't have a support to apply evolution by hand...

But, as said in the error message, you can activate a configuration key in the application.conf file: applyEvolutions.default=true

Enabling will tell Play to autoly apply all evolutions!

But take with care to your update scripts... if you drop and recreate every incremental version => you'll kill all your data !

like image 200
Andy Petrella Avatar answered Nov 16 '22 02:11

Andy Petrella


An alternative to andy's solution could be adding the following to the heroku procfile

web: target/start -Dhttp.port=${PORT} -DapplyEvolutions.default=true
  -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=$DATABASE_URL

($PORT and $DATABASE_URL will be populated by environment variables on the Heroku side)

like image 42
Kummo Avatar answered Nov 16 '22 02:11

Kummo