I just tested out Flyway
for DB Migration, and was pleasantly surprised at its capabilities and workflow.
However, there was one issue: Flyway
can also perform a clean
task which effectively drops all tables and procedures from the schema you are accessing.
This subtask should for example be runnable in a development environment, but not in a production environment: it is possible that someone misunderstands its meaning and kills the production DB by mistake.
Is it possible to disable (or simply remove) the plugin's subtask? I can do something like:
flywayClean {
enabled = project.hasProperty('devenv')
if(!enabled) {
throw new StopExecutionException("Disabled on production servers.")
}
}
But unfortunately this stops the build from completing. Ideally, I want to throw such an exception only when the task is specifically run, either from another task or from the command line.
Can I do this with Gradle?
EDIT:
Shortly after posting the question I noticed that the flyway
configuration options also included a cleanDisabled
option which can do exactly what I wished. So as to not have to delete the question though: is this possible in general, if the plugin itself does not have such an option?