Skip to content

Commit cfc0eec

Browse files
committed
Merge pull request #20417 from ferengra
* gh-20417: Polish "Add clearChecksums to Liquibase auto-configuration" Add clearCheckSums to Liquibase auto configuration Closes gh-20417
2 parents 4fd8f37 + 77dbe99 commit cfc0eec

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
* @author Dominic Gunn
6565
* @author Dan Zheng
6666
* @author András Deák
67+
* @author Ferenc Gratzer
6768
* @since 1.1.0
6869
*/
6970
@Configuration(proxyBeanMethods = false)
@@ -100,6 +101,7 @@ public SpringLiquibase liquibase(DataSourceProperties dataSourceProperties,
100101
SpringLiquibase liquibase = createSpringLiquibase(liquibaseDataSource.getIfAvailable(),
101102
dataSource.getIfUnique(), dataSourceProperties);
102103
liquibase.setChangeLog(this.properties.getChangeLog());
104+
liquibase.setClearCheckSums(this.properties.isClearChecksums());
103105
liquibase.setContexts(this.properties.getContexts());
104106
liquibase.setDefaultSchema(this.properties.getDefaultSchema());
105107
liquibase.setLiquibaseSchema(this.properties.getLiquibaseSchema());

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
*
3030
* @author Marcel Overdijk
3131
* @author Eddú Meléndez
32+
* @author Ferenc Gratzer
3233
* @since 1.1.0
3334
*/
3435
@ConfigurationProperties(prefix = "spring.liquibase", ignoreUnknownFields = false)
@@ -39,6 +40,12 @@ public class LiquibaseProperties {
3940
*/
4041
private String changeLog = "classpath:/db/changelog/db.changelog-master.yaml";
4142

43+
/**
44+
* Whether to clear all checksums in the current changelog, so they will be
45+
* recalculated upon the next update.
46+
*/
47+
private boolean clearChecksums;
48+
4249
/**
4350
* Comma-separated list of runtime contexts to use.
4451
*/
@@ -187,6 +194,14 @@ public void setDropFirst(boolean dropFirst) {
187194
this.dropFirst = dropFirst;
188195
}
189196

197+
public boolean isClearChecksums() {
198+
return this.clearChecksums;
199+
}
200+
201+
public void setClearChecksums(boolean clearChecksums) {
202+
this.clearChecksums = clearChecksums;
203+
}
204+
190205
public boolean isEnabled() {
191206
return this.enabled;
192207
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
* @author Dominic Gunn
7070
* @author András Deák
7171
* @author Andrii Hrytsiuk
72+
* @author Ferenc Gratzer
7273
*/
7374
@ExtendWith(OutputCaptureExtension.class)
7475
class LiquibaseAutoConfigurationTests {
@@ -106,6 +107,7 @@ void defaultSpringLiquibase() {
106107
assertThat(liquibase.getContexts()).isNull();
107108
assertThat(liquibase.getDefaultSchema()).isNull();
108109
assertThat(liquibase.isDropFirst()).isFalse();
110+
assertThat(liquibase.isClearCheckSums()).isFalse();
109111
}));
110112
}
111113

@@ -143,6 +145,7 @@ void defaultValues() {
143145
assertThat(liquibase.getDatabaseChangeLogLockTable())
144146
.isEqualTo(properties.getDatabaseChangeLogLockTable());
145147
assertThat(liquibase.isDropFirst()).isEqualTo(properties.isDropFirst());
148+
assertThat(liquibase.isClearCheckSums()).isEqualTo(properties.isClearChecksums());
146149
assertThat(liquibase.isTestRollbackOnUpdate()).isEqualTo(properties.isTestRollbackOnUpdate());
147150
}));
148151
}
@@ -189,6 +192,13 @@ void overrideDropFirst() {
189192
.run(assertLiquibase((liquibase) -> assertThat(liquibase.isDropFirst()).isTrue()));
190193
}
191194

195+
@Test
196+
void overrideClearChecksums() {
197+
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
198+
.withPropertyValues("spring.liquibase.clear-checksums:true")
199+
.run(assertLiquibase((liquibase) -> assertThat(liquibase.isClearCheckSums()).isTrue()));
200+
}
201+
192202
@Test
193203
void overrideDataSource() {
194204
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)

0 commit comments

Comments
 (0)