I recently started a new project, based from the scala-play-react-seed.
I have a little experience with Play and have other projects that use play-slick and slick-evolutions - everything works fine and the evolutions are recognised and applied at startup.
In the new project, this isn't happening. My connection to the database is all OK so that's not the issue.
I don't get any errors or warnings about the evolutions, as far as I can see.
I have tried explicitly turning them on in application.conf
.
This is my build.sbt
:
// core
libraryDependencies ++= Seq(
evolutions,
ehcache,
ws,
specs2 % Test,
guice)
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "4.0.2" % Test
// database
libraryDependencies += "com.typesafe.play" %% "play-slick" % "4.0.2"
libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "4.0.2"
libraryDependencies += "org.postgresql" % "postgresql" % "9.4-1201-jdbc41"
I have a suspicion that the hook into the React UI is blocking the backend from picking up those files somehow, but have no idea where to start looking. Any help greatly appreciated.
I'm pretty sure my application.conf
is set up correctly but here it is:
slick.dbs.default.profile = "slick.jdbc.PostgresProfile$"
slick.dbs.default.db.driver = "org.postgresql.Driver"
slick.dbs.default.db.url = "jdbc:postgresql://localhost:5432/standups?user=postgres&password=password"
As I said before Im pretty sure this is set up correctly because I can talk to the database. It's just the evolutions that aren't being picked up.
This is my 1.sql
, which resides in conf/evolutions/default
:
-- !Ups
create table person
(
id serial not null primary key,
name varchar(255) not null,
age smallint not null
);
-- !Downs
drop table if exists person cascade;
It's unclear to me why your evolutions aren't running.
I've tried to emulate your set up in this commit: https://github.com/d6y/scala-play-react-seed/commit/408853bda6f26a7a4fdc49487c2bb00d243ac0dc
...where I had to modify the FrontendRunHook
to actually start the front-end and the server (via https://github.com/yohangz/scala-play-react-seed/pull/30).
Other than that, sbt run
started the application and applied the evolution (verified by looking in the database).
I added play.evolutions.db.default.autoApply = true
, but without that you would have been told the database needs a migration.
I'm also using JDK 8 with this, to avoid a warning relating to Guice (WARNING: An illegal reflective access operation has occurred
). However, you didn't mention you saw that, so that's also probably unrelated.