playframework/playframework — pull request #2436 by jroper (2014-08-29 04:52:52+00:00)
Title: Evolutions plugin tries to lock datasource before checking if evolutions are even supposed to be run against the datasource

There appears to be a problem with the Evolutions plugin in 2.2.x (and in master) when using multiple datasources, and only one datasource is configured to have evolutions applied. It seems that the plugin tries to create the lock table in the database before checking if that database has the "applyEvolutions" config property set. And if one of the datasources doesn't support evolution syntax (like in our case a MySQL database), this causes an error with the evolution process.

Looking at this code:
https://github.com/playframework/playframework/blob/2.2.x/framework/src/play-jdbc/src/main/scala/play/api/db/evolutions/Evolutions.scala#L461-L466

```scala
/**
* Checks the evolutions state.
*/
override def onStart() {
dbApi.datasources.foreach {
case (ds, db) => {
withLock(ds) {
val script = evolutionScript(dbApi, app.path, app.classloader, db)
val hasDown = script.exists(_.isInstanceOf[DownScript])

lazy val applyEvolutions = app.configuration.getBoolean("applyEvolutions." + db).getOrElse(false)
lazy val applyDownEvolutions = app.configuration.getBoolean("applyDownEvolutions." + db).getOrElse(false)
```