2
votes

We've run into a bunch of problems using play-slick so I've reverted to a straight-up Slick 3.1.1 implementation.

This fixed our various problems with concurrency but... now I'm trying to add evolutions, and it doesn't seem to be working. I've added the following to build.sbt:

libraryDependencies ++= Seq( "com.typesafe.slick" %% "slick" % "3.1.1", "com.typesafe.play" %% "play-slick-evolutions" % "1.1.1", ...

And, when I did I noticed the "play-slick-evolutions" and thought, "Oh no, I bet those only with with play-slick." Seems to be the case, because the evolutions are not firing.

When I try to turn them on I get the following exceptions:

[error]   ! work from within a browser
[error]    com.google.inject.CreationException: Unable to create injector, see the following errors:
[error]
[error]    1) No implementation for play.api.db.DBApi was bound.
[error]      while locating play.api.db.DBApi
[error]        for parameter 3 at play.api.db.evolutions.ApplicationEvolutionsProvider.<init>(EvolutionsModule.scala:45)
[error]      at play.api.db.evolutions.EvolutionsModule.bindings(EvolutionsModule.scala:22):
[error]    Binding(class play.api.db.evolutions.ApplicationEvolutions to ProviderConstructionTarget(class play.api.db.evolutions.ApplicationEvolutionsProvider) eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
[error]
[error]    2) No implementation for play.api.db.DBApi was bound.
[error]      while locating play.api.db.DBApi
[error]        for parameter 0 at play.api.db.evolutions.DefaultEvolutionsApi.<init>(EvolutionsApi.scala:71)
[error]      at play.api.db.evolutions.EvolutionsModule.bindings(EvolutionsModule.scala:21):
[error]    Binding(interface play.api.db.evolutions.EvolutionsApi to ConstructionTarget(class play.api.db.evolutions.DefaultEvolutionsApi)) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$1)
[error]
[error]    2 errors (Errors.java:466)
[error] com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:466)
[error] com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:155)
[error] com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
[error] com.google.inject.Guice.createInjector(Guice.java:96)
[error] com.google.inject.Guice.createInjector(Guice.java:73)
[error] com.google.inject.Guice.createInjector(Guice.java:62)
[error] play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:126)
[error] play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:93)
[error] play.api.test.FakeApplication.<init>(Fakes.scala:216)
[error] play.api.test.WithBrowser$.$lessinit$greater$default$2(Specs.scala:74)
[error] application.TestBrowserResponses$$anonfun$1$$anonfun$apply$1$$anon$1.<init>(TestBrowserResponses.scala:8)
[error] application.TestBrowserResponses$$anonfun$1$$anonfun$apply$1.apply(TestBrowserResponses.scala:8)
[error] application.TestBrowserResponses$$anonfun$1$$anonfun$apply$1.apply(TestBrowserResponses.scala:8)

Anyone know if it's possible to use evolutions with just plain Slick?

2
I'm also looking for a solution to this problem as I am experiencing this as well.nmurthy

2 Answers

1
votes

Yes, Evolutions can be used with plain Slick without using play-slick.

You can add dependencies with

libraryDependencies += evolutions

Also, make sure play.evolutions.enabled is not set to false in application.conf to trigger evolutions.

Evolutions are automatically activated if a database is configured in application.conf and evolution scripts are present.

Please refer to Evolutions documentation for more details.

Update: Regarding the exception you are getting. Refer to this documentation. https://www.playframework.com/documentation/2.4.x/PlaySlickFAQ#A-binding-to-play.api.db.DBApi-was-already-configured

0
votes

You might have to add your sql app specific jdbc driver to build.sbt, because slick comes without it. For example:

libraryDependencies ++= Seq(
  "org.xerial" % "sqlite-jdbc" % "3.8.11.2",
  "com.typesafe.play" %% "play-slick" % "2.0.0",
  "com.typesafe.play" %% "play-slick-evolutions" % "2.0.0"
)