Merge pull request #20417 from ferengra
* gh-20417: Polish "Add clearChecksums to Liquibase auto-configuration" Add clearCheckSums to Liquibase auto configuration Closes gh-20417
This commit is contained in:
@@ -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)
|
||||
@@ -100,6 +101,7 @@ public class LiquibaseAutoConfiguration {
|
||||
SpringLiquibase liquibase = createSpringLiquibase(liquibaseDataSource.getIfAvailable(),
|
||||
dataSource.getIfUnique(), dataSourceProperties);
|
||||
liquibase.setChangeLog(this.properties.getChangeLog());
|
||||
liquibase.setClearCheckSums(this.properties.isClearChecksums());
|
||||
liquibase.setContexts(this.properties.getContexts());
|
||||
liquibase.setDefaultSchema(this.properties.getDefaultSchema());
|
||||
liquibase.setLiquibaseSchema(this.properties.getLiquibaseSchema());
|
||||
|
||||
@@ -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)
|
||||
@@ -39,6 +40,12 @@ public class LiquibaseProperties {
|
||||
*/
|
||||
private String changeLog = "classpath:/db/changelog/db.changelog-master.yaml";
|
||||
|
||||
/**
|
||||
* Whether to clear all checksums in the current changelog, so they will be
|
||||
* recalculated upon the next update.
|
||||
*/
|
||||
private boolean clearChecksums;
|
||||
|
||||
/**
|
||||
* Comma-separated list of runtime contexts to use.
|
||||
*/
|
||||
@@ -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-checksums:true")
|
||||
.run(assertLiquibase((liquibase) -> assertThat(liquibase.isClearCheckSums()).isTrue()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void overrideDataSource() {
|
||||
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
|
||||
|
||||
Reference in New Issue
Block a user