我在SQLite
终端上创建了一个Ubuntu
数据库,
$ sqlite users.db
然后我将users.db
文件移到了projectDir/conf/application.conf
。
后来我写了一个Evolution,但是当我通过users.db
查看数据库时,它并没有应用于我的DBeaver
数据库。
这是我的application.conf
文件
play.http.secret.key = "changeme"
play.i18n {
langs = [ "en" ]
}
play.filters {
enabled += filters.ExampleFilter
}
play.evolutions.db.default {
enabled = true
autoApply = true
autoApplyDowns = true
}
slick.dbs.default {
profile = "slick.jdbc.SQLiteProfile$"
driver = "slick.driver.SQLiteDriver$"
db.driver = "org.sqlite.JDBC"
db.url = "jdbc:sqlite:/home/saad/play-scala-starter-example/conf/users.db"
}
play.assets {
path = "/public"
urlPrefix = "/assets"
}
这是我的build.sbt
name := """play-scala-starter-example"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
resolvers += Resolver.sonatypeRepo("snapshots")
scalaVersion := "2.12.7"
crossScalaVersions := Seq("2.11.12", "2.12.7")
libraryDependencies += guice
libraryDependencies += "org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2" % Test
libraryDependencies += "com.typesafe.slick" %% "slick" % "3.2.0"
libraryDependencies += "com.typesafe.slick" %% "slick-codegen" % "3.2.3"
libraryDependencies += evolutions
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-slick" % "3.0.0",
"com.typesafe.play" %% "play-slick-evolutions" % "3.0.0"
)
libraryDependencies ++= Seq(
cache,
javaWs,
"org.xerial" % "sqlite-jdbc" % "3.23.1"
)
这是我的1.sql
文件,我已经测试过代码没有错误。
# --- !Ups
CREATE TABLE IF NOT EXISTS Users(
ID INTEGER PRIMARY KEY AUTOINCREMENT,
LastName varchar(255) NOT NULL,
FirstName varchar(255) NOT NULL,
Password varchar(255) NOT NULL,
Email varchar(255) NOT NULL UNIQUE,
Authenticated boolean
);
INSERT INTO Users(LastName, FirstName, Password, Email, Authenticated) VALUES ('Saad', 'Ali', 'spadsdditcom', 'asdasdasd', 1);
# --- !Downs
DROP TABLE IF EXISTS Users
我完成sbt run
之后,index
页面打开,没有错误,但是从DBeaver
看,进化也没有应用。
我的问题是,我在做什么错了?
答案 0 :(得分:1)
我知道了,我将1.sql
放置在conf/dafault.evolution
中而不是conf/dafault/evolution
中。
愚蠢的错误,是的。