1
votes

I'm trying to run Play framework 2.5 application with postgresql database using slick. But evolutions are not detected after I've added 1.sql to conf/evolutions/default. What am I doing wrong?

Application.conf

play.evolutions {
  db.default.enabled = true
}
evolutions.autocommit=false
db {
  slick.dbs.default.driver = "org.postgresql.Driver"
  slick.dbs.default.db.driver = "com.postgresql.jdbc.Driver"
  slick.dbs.default.db.url = "jdbc:mysql://localhost/doctor_moda"
  slick.dbs.default.db.user = "doctor_moda"
  slick.dbs.default.db.password = "doctor_moda"
}

build.sbt

name := """doctor_moda"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.7"

libraryDependencies ++= Seq(
  cache,
  evolutions,
  ws,
  "org.scalatestplus.play" %% "scalatestplus-play" % "1.5.1" % Test,
  "com.typesafe.slick" %% "slick" % "3.1.1",
  "org.slf4j" % "slf4j-nop" % "1.6.4",
  "com.typesafe.slick" %% "slick-hikaricp" % "3.1.0",
  "org.postgresql" % "postgresql" % "9.4-1201-jdbc41",
  "com.typesafe.play" %% "play-slick-evolutions" % "1.1.1"
)

1.sql

# Initial version

# --- !Ups
CREATE SCHEMA role;

CREATE TABLE role.users (
    id PRIMARY KEY DEFAULT nextval('serial'),
    username VARCHAR NOT NULL UNIQUE,
    email VARCHAR NOT NULL UNIQUE
        CHECK (email ~* '^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$'),
    password VARCHAR NOT NULL,
    salt VARCHAR NOT NULL,
    created DATE NOT NULL
);

# --- !Downs
DROP SCHEMA role;

-- User schema
1
Can you try moving your slick.dbs.default conf part outside of the db object in your configuration?mfirry

1 Answers

0
votes

I've found a problem. Correct application config should consist

slick.dbs.default.driver = "org.postgresql.Driver"
  slick.dbs.default.db.driver = "com.postgresql.jdbc.Driver"
  slick.dbs.default.db.url = "jdbc:postgresql://localhost/doctor_moda"
  slick.dbs.default.db.user = ***
  slick.dbs.default.db.password = ***