Commit a2680efa authored by ferengra's avatar ferengra Committed by Andy Wilkinson

Add clearCheckSums to Liquibase auto configuration

Liquibase auto configuration is extended with clearCheckSums to allow
to clear all checksums in the current changelog, so they will be
recalculated upon the next update.

See gh-20417
parent 4fd8f376
......@@ -64,6 +64,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
* @author Dominic Gunn
* @author Dan Zheng
* @author András Deák
* @author Ferenc Gratzer
* @since 1.1.0
*/
@Configuration(proxyBeanMethods = false)
......@@ -107,6 +108,7 @@ public class LiquibaseAutoConfiguration {
liquibase.setDatabaseChangeLogTable(this.properties.getDatabaseChangeLogTable());
liquibase.setDatabaseChangeLogLockTable(this.properties.getDatabaseChangeLogLockTable());
liquibase.setDropFirst(this.properties.isDropFirst());
liquibase.setClearCheckSums(this.properties.isClearCheckSums());
liquibase.setShouldRun(this.properties.isEnabled());
liquibase.setLabels(this.properties.getLabels());
liquibase.setChangeLogParameters(this.properties.getParameters());
......
......@@ -29,6 +29,7 @@ import org.springframework.util.Assert;
*
* @author Marcel Overdijk
* @author Eddú Meléndez
* @author Ferenc Gratzer
* @since 1.1.0
*/
@ConfigurationProperties(prefix = "spring.liquibase", ignoreUnknownFields = false)
......@@ -74,6 +75,12 @@ public class LiquibaseProperties {
*/
private boolean dropFirst;
/**
* Whether to clear all checksums in the current changelog, so they will be
* recalculated next update.
*/
private boolean clearCheckSums;
/**
* Whether to enable Liquibase support.
*/
......@@ -187,6 +194,14 @@ public class LiquibaseProperties {
this.dropFirst = dropFirst;
}
public boolean isClearCheckSums() {
return this.clearCheckSums;
}
public void setClearCheckSums(boolean clearCheckSums) {
this.clearCheckSums = clearCheckSums;
}
public boolean isEnabled() {
return this.enabled;
}
......
......@@ -69,6 +69,7 @@ import static org.assertj.core.api.Assertions.contentOf;
* @author Dominic Gunn
* @author András Deák
* @author Andrii Hrytsiuk
* @author Ferenc Gratzer
*/
@ExtendWith(OutputCaptureExtension.class)
class LiquibaseAutoConfigurationTests {
......@@ -106,6 +107,7 @@ class LiquibaseAutoConfigurationTests {
assertThat(liquibase.getContexts()).isNull();
assertThat(liquibase.getDefaultSchema()).isNull();
assertThat(liquibase.isDropFirst()).isFalse();
assertThat(liquibase.isClearCheckSums()).isFalse();
}));
}
......@@ -143,6 +145,7 @@ class LiquibaseAutoConfigurationTests {
assertThat(liquibase.getDatabaseChangeLogLockTable())
.isEqualTo(properties.getDatabaseChangeLogLockTable());
assertThat(liquibase.isDropFirst()).isEqualTo(properties.isDropFirst());
assertThat(liquibase.isClearCheckSums()).isEqualTo(properties.isClearCheckSums());
assertThat(liquibase.isTestRollbackOnUpdate()).isEqualTo(properties.isTestRollbackOnUpdate());
}));
}
......@@ -189,6 +192,13 @@ class LiquibaseAutoConfigurationTests {
.run(assertLiquibase((liquibase) -> assertThat(liquibase.isDropFirst()).isTrue()));
}
@Test
void overrideClearCheckSums() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.clear-check-sums:true")
.run(assertLiquibase((liquibase) -> assertThat(liquibase.isClearCheckSums()).isTrue()));
}
@Test
void overrideDataSource() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment