diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java index 0ef3992e0b..7130d9c7b3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java @@ -129,6 +129,7 @@ public class LiquibaseAutoConfiguration { liquibase.setLabels(this.properties.getLabels()); liquibase.setChangeLogParameters(this.properties.getParameters()); liquibase.setRollbackFile(this.properties.getRollbackFile()); + liquibase.setTestRollbackOnUpdate(this.properties.isTestRollbackOnUpdate()); return liquibase; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java index 64e7d3f27b..62f906c165 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,6 +94,11 @@ public class LiquibaseProperties { */ private File rollbackFile; + /** + * Whether rollback should be tested before update is performed. + */ + private boolean testRollbackOnUpdate; + public String getChangeLog() { return this.changeLog; } @@ -191,4 +196,12 @@ public class LiquibaseProperties { this.rollbackFile = rollbackFile; } + public boolean isTestRollbackOnUpdate() { + return this.testRollbackOnUpdate; + } + + public void setTestRollbackOnUpdate(boolean testRollbackOnUpdate) { + this.testRollbackOnUpdate = testRollbackOnUpdate; + } + } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java index 1e50fc083b..3e9b2490ea 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java @@ -178,6 +178,18 @@ public class LiquibaseAutoConfigurationTests { })); } + @Test + public void overrideTestRollbackOnUpdate() { + this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) + .withPropertyValues( + "spring.liquibase.test-rollback-on-update:true") + .run((context) -> { + SpringLiquibase liquibase = context.getBean(SpringLiquibase.class); + assertThat(liquibase.isTestRollbackOnUpdate()).isTrue(); + }); + } + + @Test public void changeLogDoesNotExist() { this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 74e200d077..c3f9721799 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -567,6 +567,7 @@ content into your application. Rather, pick only the properties that you need. spring.liquibase.parameters.*= # Change log parameters. spring.liquibase.password= # Login password of the database to migrate. spring.liquibase.rollback-file= # File to which rollback SQL is written when an update is performed. + spring.liquibase.test-rollback-on-update=false # Whether rollback should be tested before update is performed. spring.liquibase.url= # JDBC URL of the database to migrate. If not set, the primary configured data source is used. spring.liquibase.user= # Login user of the database to migrate.