Commit 77dbe999 authored by Andy Wilkinson's avatar Andy Wilkinson

Polish "Add clearChecksums to Liquibase auto-configuration"

See gh-20417
parent a2680efa
...@@ -101,6 +101,7 @@ public class LiquibaseAutoConfiguration { ...@@ -101,6 +101,7 @@ public class LiquibaseAutoConfiguration {
SpringLiquibase liquibase = createSpringLiquibase(liquibaseDataSource.getIfAvailable(), SpringLiquibase liquibase = createSpringLiquibase(liquibaseDataSource.getIfAvailable(),
dataSource.getIfUnique(), dataSourceProperties); dataSource.getIfUnique(), dataSourceProperties);
liquibase.setChangeLog(this.properties.getChangeLog()); liquibase.setChangeLog(this.properties.getChangeLog());
liquibase.setClearCheckSums(this.properties.isClearChecksums());
liquibase.setContexts(this.properties.getContexts()); liquibase.setContexts(this.properties.getContexts());
liquibase.setDefaultSchema(this.properties.getDefaultSchema()); liquibase.setDefaultSchema(this.properties.getDefaultSchema());
liquibase.setLiquibaseSchema(this.properties.getLiquibaseSchema()); liquibase.setLiquibaseSchema(this.properties.getLiquibaseSchema());
...@@ -108,7 +109,6 @@ public class LiquibaseAutoConfiguration { ...@@ -108,7 +109,6 @@ public class LiquibaseAutoConfiguration {
liquibase.setDatabaseChangeLogTable(this.properties.getDatabaseChangeLogTable()); liquibase.setDatabaseChangeLogTable(this.properties.getDatabaseChangeLogTable());
liquibase.setDatabaseChangeLogLockTable(this.properties.getDatabaseChangeLogLockTable()); liquibase.setDatabaseChangeLogLockTable(this.properties.getDatabaseChangeLogLockTable());
liquibase.setDropFirst(this.properties.isDropFirst()); liquibase.setDropFirst(this.properties.isDropFirst());
liquibase.setClearCheckSums(this.properties.isClearCheckSums());
liquibase.setShouldRun(this.properties.isEnabled()); liquibase.setShouldRun(this.properties.isEnabled());
liquibase.setLabels(this.properties.getLabels()); liquibase.setLabels(this.properties.getLabels());
liquibase.setChangeLogParameters(this.properties.getParameters()); liquibase.setChangeLogParameters(this.properties.getParameters());
......
...@@ -40,6 +40,12 @@ public class LiquibaseProperties { ...@@ -40,6 +40,12 @@ public class LiquibaseProperties {
*/ */
private String changeLog = "classpath:/db/changelog/db.changelog-master.yaml"; 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. * Comma-separated list of runtime contexts to use.
*/ */
...@@ -75,12 +81,6 @@ public class LiquibaseProperties { ...@@ -75,12 +81,6 @@ public class LiquibaseProperties {
*/ */
private boolean dropFirst; 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. * Whether to enable Liquibase support.
*/ */
...@@ -194,12 +194,12 @@ public class LiquibaseProperties { ...@@ -194,12 +194,12 @@ public class LiquibaseProperties {
this.dropFirst = dropFirst; this.dropFirst = dropFirst;
} }
public boolean isClearCheckSums() { public boolean isClearChecksums() {
return this.clearCheckSums; return this.clearChecksums;
} }
public void setClearCheckSums(boolean clearCheckSums) { public void setClearChecksums(boolean clearChecksums) {
this.clearCheckSums = clearCheckSums; this.clearChecksums = clearChecksums;
} }
public boolean isEnabled() { public boolean isEnabled() {
......
...@@ -145,7 +145,7 @@ class LiquibaseAutoConfigurationTests { ...@@ -145,7 +145,7 @@ class LiquibaseAutoConfigurationTests {
assertThat(liquibase.getDatabaseChangeLogLockTable()) assertThat(liquibase.getDatabaseChangeLogLockTable())
.isEqualTo(properties.getDatabaseChangeLogLockTable()); .isEqualTo(properties.getDatabaseChangeLogLockTable());
assertThat(liquibase.isDropFirst()).isEqualTo(properties.isDropFirst()); assertThat(liquibase.isDropFirst()).isEqualTo(properties.isDropFirst());
assertThat(liquibase.isClearCheckSums()).isEqualTo(properties.isClearCheckSums()); assertThat(liquibase.isClearCheckSums()).isEqualTo(properties.isClearChecksums());
assertThat(liquibase.isTestRollbackOnUpdate()).isEqualTo(properties.isTestRollbackOnUpdate()); assertThat(liquibase.isTestRollbackOnUpdate()).isEqualTo(properties.isTestRollbackOnUpdate());
})); }));
} }
...@@ -193,9 +193,9 @@ class LiquibaseAutoConfigurationTests { ...@@ -193,9 +193,9 @@ class LiquibaseAutoConfigurationTests {
} }
@Test @Test
void overrideClearCheckSums() { void overrideClearChecksums() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.clear-check-sums:true") .withPropertyValues("spring.liquibase.clear-checksums:true")
.run(assertLiquibase((liquibase) -> assertThat(liquibase.isClearCheckSums()).isTrue())); .run(assertLiquibase((liquibase) -> assertThat(liquibase.isClearCheckSums()).isTrue()));
} }
......
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