1

I followed the Scala Play 2.1.x tutorial to created a todolist application.

On local development environment + local Heroku Postgres: The evolution is executed automatically. The app works perfectly fine.

On Heroku, the evolution is not executed at all. Therefore, I will get a relation does not exist error.

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

Attempts

  1. Move db.default.url, db.default.driver & applyEvolutions.default to application.conf.
  2. Used instructions from the accepted answer in this question Errors in evolutions on Heroku. Connected to the remote Heroku Postgres DB from my local development machine and run the evolution - it works perfectly.
  3. I installed Play 2.2.1 and attempted the same tutorial, I encounter the same problem.

Since I am able to execute evolutions from my local dev machine onto the remote Heroku Postgres DB. The problem seems to happen only when it is on the Heroku environment.

Community
  • 1
  • 1
tommi
  • 6,883
  • 8
  • 37
  • 60

3 Answers3

4

I made a very bad mistake - the evolution script was gitignored. Which means it was never deployed to Heroku, so there was nothing for Play's evolutions to execute.

To be exact, the evolution script, *.sql, was gitignored by my global gitignore setting. The .gitignore that came with play new appname works perfectly fine.

tommi
  • 6,883
  • 8
  • 37
  • 60
  • This was my exact problem, thank you. To go a step further, I added this entry to my .gitignore and the play evolution sql ONLY is included now: !conf/evolutions/**/*.sql – Vincil Bishop Oct 03 '15 at 18:02
0

It seems the problem is not from Heroku but from your database in Heroku.

Do you have the a table called "play_evolutions" in your database? What is your ebean conf for Heroku?

memainjm
  • 642
  • 6
  • 11
  • Hi! Nope, I cannot find the `play_evolutions` table in the database, which is supposed to keep track of the evolutions. And nope, not using ebean for the app. – tommi Nov 30 '13 at 01:47
  • I followed http://stackoverflow.com/questions/12195568/errors-in-evolutions-on-heroku. Connect to the remote database from my local machine, and the evolution works fine. – tommi Nov 30 '13 at 02:38
0

I copy my working version posted in

Heroku - Unable to setup postgres database through Play Framework app?

In my case git init, git add ., works great. Using play 2.4, Slick 3.0.3 & postgres in Heroku it works for me the following setup that runs my sql evolution scripts:

in build.sbt:

name := """app-name"""

and add the following in libraryDependencies ++= Seq(

"com.typesafe.play" %% "play-slick" % "1.0.1",
"com.typesafe.play" %% "play-slick-evolutions" % "1.0.1",
"com.typesafe.slick" %% "slick" % "3.0.3",
"org.postgresql" % "postgresql" % "9.4-1201-jdbc41",
"org.slf4j" % "slf4j-nop" % "1.6.4",

in application.conf:

slick.dbs.default.driver ="slick.driver.PostgresDriver$"
slick.dbs.default.db.dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
slick.dbs.default.db.properties.driver = "org.postgresql.Driver"

and in Procfile:

web: target/universal/stage/bin/app-name -Dhttp.port=${PORT} -Dplay.evolutions.db.default.autoApply=true

Cheers

Community
  • 1
  • 1