Why is cleanOnValidationError deprecated?
Which version and edition of Flyway are you using?
10.18.0
Why is cleanOnValidationError deprecated? Is it replaced by another option? If not, please explain as I use this feature regularly and it saves a lot of time.
Hi @cowwoc ,
We have a blog post related to this change: https://documentation.red-gate.com/fd/deprecation-of-clean-on-validation-error-254154581.html
Hmm, couldn't you limit deprecation to TOML configuration files since they are the only ones that exhibit the problem?
The provided workaround might work for Linux shell users but I'm not sure what Maven users are supposed to do... Do you have a workaround for us?
Hi @cowwoc ,
Even with command-line configuration, this problem still exists. Configuration like -cleanOnValidationError=true is a global setting and will impact all the environments.
By Maven users, do you mean Java API users? If so, can we work around this with Java code like:
try {
flyway.validate();
} catch (FlywayValidateException e) {
flyway.clean();
}
@JasonLuo-Redgate Given:
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<executions>
<execution>
<id>migrate-db</id>
<goals>
<goal>migrate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<driver>org.postgresql.Driver</driver>
<url>${DATABASE_URL}</url>
<user>${DATABASE_USERNAME}</user>
<password>${DATABASE_PASSWORD}</password>
<locations>
<location>
filesystem:com/mycompany/migration
</location>
</locations>
<schemas>
<schema>public</schema>
</schemas>
<cleanOnValidationError>${FLYWAY_CLEAN_ON_VALIDATION_ERROR}</cleanOnValidationError>
<cleanDisabled>${FLYWAY_CLEAN_DISABLED}</cleanDisabled>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
</dependencies>
</plugin>
I have flyway migrate enable clean-on-validation-error in debug mode, and disabled in production. I can't think of a workaround for this workflow...
cleanOnValidationError is immensely useful when iterating in development, especially in combination with jOOQ and a suitable replacement when using the Maven and Gradle plugins is sorely missing.
It looks like this could be implemented in the plugin itself here: https://github.com/flyway/flyway/blob/main/flyway-plugins/flyway-maven-plugin/src/main/java/org/flywaydb/maven/ValidateMojo.java