Teimuraz
Teimuraz

Reputation: 9325

Slick (postgresql) evolutions are not being triggered in Play Framework 2.6

Here is database config in

application.conf:

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

build.sbt

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

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

resolvers += Resolver.sonatypeRepo("snapshots")

scalaVersion := "2.12.4"

libraryDependencies += guice
libraryDependencies += evolutions

libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % Test


libraryDependencies += "org.postgresql" % "postgresql" % "42.1.4"
libraryDependencies += "com.typesafe.play" %% "play-slick" % "3.0.1"
libraryDependencies += "com.typesafe.play" %% "play-slick-evolutions" % "3.0.1"

I have sql script in conf/evolutions/default folder

1.sql

# Users schema

# --- !Ups

CREATE TABLE users
(
    id bigint NOT NULL,
    email character varying(255) NOT NULL,
    username character varying(100) NOT NULL,
    password character varying(100) NOT NULL,       
    PRIMARY KEY (id)
)
WITH (
    OIDS = FALSE
);

# --- !Downs

DROP TABLE IF EXISTS users CASCADE;

But on application start, evolutions are not being triggered. Db connection works ok (I've checked by implementing some slick queries against db from this app).

What am I doing wrong here?

Upvotes: 2

Views: 568

Answers (2)

Teimuraz
Teimuraz

Reputation: 9325

I found the problem.

Evolution scripts were located under

conf/evolutions.default

but they should be located under

conf/evolutions/default

So I accidently created one folder splitted by dot under conf folder instead of two.

Upvotes: 0

Achraf Dawny jr.
Achraf Dawny jr.

Reputation: 186

Try to add this line to your application.conf :

play.evolutions.db.default.enabled = true

Upvotes: 1

Related Questions