1

我正在尝试使用 slick 运行带有 postgresql 数据库的 Play framework 2.5 应用程序。但是在我将 1.sql 添加到 conf/evolutions/default 之后,没有检测到进化。我究竟做错了什么?

应用程序.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"
}

构建.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
4

1 回答 1

0

我发现了一个问题。正确的应用程序配置应该包括

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 = ***
于 2017-04-12T14:51:41.390 回答