EVOLUTION BEFORE DEPLOYMENT
▸ Even if useLocks option is
enabled,
Evolution should be
executed carefully
▸ Execute evolutions safely
before deployments with
one-shot style as a Jenkins
job
java -Dconfig.resource=batch.conf
-Dplay.evolutions.db.default.autoApply=true
-Dplay.mode=prod
-cp ./target/scala-2.11/app-x.x.jar
tasks.EvolutionsCheckTask
One-shot evolution example
package tasks
import com.typesafe.scalalogging.LazyLogging
object EvolutionsCheckTask extends App with Task with LazyLogging
{
withApplication(
app => {
logger.info("unnecessary")
},
ex => ex match {
case ex: play.api.db.evolutions.InvalidDatabaseRevision =>
logger.warn("necessary")
case ex =>
logger.error(ex.getMessage, ex)
println("Error")
}
)
}
tasks.EvolutionsCheckTask