Skip to content

Commit a2680ef

Browse files
ferengrawilkinsona
authored andcommitted
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
1 parent 4fd8f37 commit a2680ef

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)
@@ -107,6 +108,7 @@ public SpringLiquibase liquibase(DataSourceProperties dataSourceProperties,
107108
liquibase.setDatabaseChangeLogTable(this.properties.getDatabaseChangeLogTable());
108109
liquibase.setDatabaseChangeLogLockTable(this.properties.getDatabaseChangeLogLockTable());
109110
liquibase.setDropFirst(this.properties.isDropFirst());
111+
liquibase.setClearCheckSums(this.properties.isClearCheckSums());
110112
liquibase.setShouldRun(this.properties.isEnabled());
111113
liquibase.setLabels(this.properties.getLabels());
112114
liquibase.setChangeLogParameters(this.properties.getParameters());

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)
@@ -74,6 +75,12 @@ public class LiquibaseProperties {
7475
*/
7576
private boolean dropFirst;
7677

78+
/**
79+
* Whether to clear all checksums in the current changelog, so they will be
80+
* recalculated next update.
81+
*/
82+
private boolean clearCheckSums;
83+
7784
/**
7885
* Whether to enable Liquibase support.
7986
*/
@@ -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-check-sums: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)