Playframework 播放';在使用现有数据库创建新的Play 2.6项目时,s尝试应用所有dows演进

Playframework 播放';在使用现有数据库创建新的Play 2.6项目时,s尝试应用所有dows演进,playframework,playframework-2.6,Playframework,Playframework 2.6,目前,我有一个Play 1.2.7应用程序正在生产环境中运行,并且有一个现有的Postgresql数据库。我将把我的整个应用程序迁移到Play 2.6 我读了大部分的书,但找不到解决问题的办法 事实上,我只是将现有的(1.sql->178.sql)添加到项目中,目前没有任何模型 重要事实:我刚刚发现进化脚本中有一个“漏洞”。我们有从1.sql到107.sql以及从111.sql到178.sql的脚本。108、109和110脚本丢失(我猜是开发团队犯的历史性错误) 数据库的play_evoluti

目前,我有一个Play 1.2.7应用程序正在生产环境中运行,并且有一个现有的Postgresql数据库。我将把我的整个应用程序迁移到Play 2.6

我读了大部分的书,但找不到解决问题的办法

事实上,我只是将现有的(1.sql->178.sql)添加到项目中,目前没有任何模型

重要事实:我刚刚发现进化脚本中有一个“漏洞”。我们有从1.sql到107.sql以及从111.sql到178.sql的脚本。108、109和110脚本丢失(我猜是开发团队犯的历史性错误)

数据库的play_evolutions表与此孔一致。没有id为108、109或110的行

当运行我的hello world Play 2.6应用程序时,Play希望应用所有向下,然后只应用从1到107的向上。这是一个问题,因为它会删除我所有的数据,而且这个洞似乎阻止了对107.sql的升级

我的问题是:问题是由于脚本中的漏洞还是因为我还没有集成模型?我怎样才能让游戏接受这个洞,或者手动填充它

我的演进在conf/evolutions/default中

以下是我的主要配置文件:

1) conf/application.conf

## Secret key
play.crypto.secret = "changeme"

## Internationalisation
play.i18n {
  langs = [ "fr" ]
}

## JDBC Datasource
db {
    default.driver = org.postgresql.Driver
    default.url = "postgres://user:password@localhost:5432/databasename"
    default.jndiName=DefaultDS
}

ebean.default = ["models.*"]

# Number of database connections
# See https://github.com/brettwooldridge/HikariCP/wiki/About-Pool-Sizing
fixedConnectionPool = 9

# Set Hikari to fixed size
play.db {
  prototype {
    hikaricp.minimumIdle = ${fixedConnectionPool}
    hikaricp.maximumPoolSize = ${fixedConnectionPool}
  }
}

# Job queue sized to HikariCP connection pool
database.dispatcher {
  executor = "thread-pool-executor"
  throughput = 1
  thread-pool-executor {
    fixed-pool-size = ${fixedConnectionPool}
  }
}
2) build.sbt

name := """my-app"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean)

scalaVersion := "2.12.4"

libraryDependencies += guice
libraryDependencies += "org.postgresql" % "postgresql" % "42.2.2"
libraryDependencies ++= Seq(evolutions, jdbc)


// Compile the project before generating Eclipse files, so that generated 
.scala or .class files for views and routes are present
EclipseKeys.preTasks := Seq(compile in Compile, compile in Test)


PlayKeys.devSettings += "play.server.http.port" -> "80"
3) project/plugins.sbt

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.15")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "4.1.3")

我终于找到了解决办法

我刚刚从conf/evolutions文件夹中删除了所有脚本(178*.sql文件)。我还删除了数据库play_evolutions表中的所有行

最后,我添加了一个1.sql空文件(如果没有它,Play会根据模型自动生成DDL脚本)

因此,在迁移我的应用程序时,我启动了一个新的Play 2.6项目,丢失了所有过去的演变,并保留了数据


也许这是现在最好的方法,但如果它能帮助别人的话

您可以在application.conf中添加play.evolutions.autoApplyDowns=false,告诉play不要应用脚本

这是建议在生产