flyway icon indicating copy to clipboard operation
flyway copied to clipboard

Why is cleanOnValidationError deprecated?

Open cowwoc opened this issue 1 year ago • 6 comments

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.

cowwoc avatar Sep 17 '24 15:09 cowwoc

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

JasonLuo-Redgate avatar Sep 18 '24 13:09 JasonLuo-Redgate

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?

cowwoc avatar Sep 18 '24 23:09 cowwoc

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 avatar Sep 19 '24 09:09 JasonLuo-Redgate

@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...

cowwoc avatar Sep 20 '24 19:09 cowwoc

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.

axelfontaine avatar Jul 06 '25 15:07 axelfontaine

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

liry avatar Sep 04 '25 13:09 liry