1
votes

I'm starting a small personal project in play framework 2.4 I want to use slick 3 and liquibase for handling db queries na db schema management. Right at the start i faced some issues in configuration.

In nutshell.

I created simple app from activator(play-scala seed). I added slick to the project. I tried to connect liquibase to my application accordingly to instruction: https://github.com/Ticketfly/play-liquibase

I added two files:

<!-- conf/liquibase/changelog.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
       a xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

    <include file="conf/liquibase/changelogs/changelog-1.xml"/>

</databaseChangeLog>

and

<!-- conf/liquibase/changelogs/changelog-1.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
         http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.4.xsd">

    <changeSet id="create application schema" author="author">
        <sql>
            create schema appschema;
        </sql>
    </changeSet>

</databaseChangeLog>

then i try to run application in terminal with: activator -> run(app runs but i can't see effects of changesets nor any error message)

Any idea what am I missing?

I attach build.sbt and application.conf

build.sbt

import sbt.project

name := "projecta"
version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  jdbc,
  cache,
  ws,
  specs2 % Test,
  "com.typesafe.play" %% "play-slick" % "1.1.1",
  "com.typesafe.play" %% "play-slick-evolutions" % "1.1.1",
  "com.ticketfly" %% "play-liquibase" % "1.0"
)

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

routesGenerator := InjectedRoutesGenerator

application.conf

fork in run := true

slick.dbs.default.driver="slick.driver.PostgresDriver$"
slick.dbs.default.db.driver="org.postgresql.Driver"
slick.dbs.default.db.url="jdbc:postgresql://localhost:5432/projecta"
slick.dbs.default.db.user="postgres"
slick.dbs.default.db.password="postgres"

liquibase {
  url      = "jdbc:postgresql://localhost:5432/projecta"
  driver   = "org.postgresql.Driver"
  user     = "postgres"
  password = "postgres"
}

liquibase.enable = true
1
The problem was on my side. I thought that changesets should run on app start but, in fact ,they do run on first request.viniolli
Also, you don't need play-slick-evolutions since you are using liquibase for schema evolutions.Dragisa Krsmanovic

1 Answers

0
votes

Looks you are missing adding reference to Postgres Driver. You may want to add below postgress ref to your library dependencies.

"org.postgresql" % "postgresql" % "9.4.1207"