ben-manes/gradle-flyway-plugin — pull request #2 by alkamo (2013-05-09 14:24:22+00:00)
Title: Deploying to Multiple Databases

This one's a little more complex...

I'm in a situation where we need to be able to deploy to multiple database as part of a single release. I couldn't find a manageable way to do this with the existing plug-in, so I extended it. Part of my goal was to retain compatibility with the existing project. I also liked the idea that, when deploying to multiple databases, the existing ```flyway``` extension could be used as set of defaults.

The changes are summarized:

* FlywayPlugin.groovy: Added a new extension, named ```flywayMulti```, which is a container of ```flywayExtension``` objects.
* FlywayExtension.groovy: Added a ```name``` property and a second constructor to populate it, which is required to use the class in a container. Also added the ```schemaGenericFirst``` property to indicate whether schemas in ```flyway``` or ```flywayMulti``` should come first when combining them (necessary because Flyway looks for the versioning table in the first schema listed).
* AbstractFlywayTask.groovy:
- Constructor: Gathers ```dependsOnTasks``` from main ```flyway``` extension and all ```flywayMulti``` objects.
- runTask: If ```flywayMulti``` contains no objects, runs once using ```flyway``` as before. Otherwise, runs once for each object in ```flywayMulti```.
- create: Passes current configuration to each sub-task.
- add*: Added ```FlywayExtension``` parameter, in order to know which database to run against. In most cases, uses the value from the passed object if it is not null, otherwise uses the object from ```flyway```. For lists, it concatenates the two lists, rather than use one in preference to the other.
* README.md: Added description and example of a multiple database release.