Merge pull request #19316 from eddumelendez

* pr/19316:
  Polish "Add support for configuring Liquibase tag property"
  Add support for configuring Liquibase tag property

Closes gh-19316
pull/20210/head
Stephane Nicoll 5 years ago
commit d4c7315369

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@ -112,6 +112,7 @@ public class LiquibaseAutoConfiguration {
liquibase.setChangeLogParameters(this.properties.getParameters());
liquibase.setRollbackFile(this.properties.getRollbackFile());
liquibase.setTestRollbackOnUpdate(this.properties.isTestRollbackOnUpdate());
liquibase.setTag(this.properties.getTag());
return liquibase;
}

@ -28,6 +28,7 @@ import org.springframework.util.Assert;
* Configuration properties to configure {@link SpringLiquibase}.
*
* @author Marcel Overdijk
* @author Eddú Meléndez
* @since 1.1.0
*/
@ConfigurationProperties(prefix = "spring.liquibase", ignoreUnknownFields = false)
@ -114,6 +115,13 @@ public class LiquibaseProperties {
*/
private boolean testRollbackOnUpdate;
/**
* Tag name to use when applying database changes. Can also be used with
* "rollbackFile" to generate a rollback script for all existing changes associated
* with that tag.
*/
private String tag;
public String getChangeLog() {
return this.changeLog;
}
@ -243,4 +251,12 @@ public class LiquibaseProperties {
this.testRollbackOnUpdate = testRollbackOnUpdate;
}
public String getTag() {
return this.tag;
}
public void setTag(String tag) {
this.tag = tag;
}
}

@ -343,6 +343,13 @@ class LiquibaseAutoConfigurationTests {
});
}
@Test
void overrideTag() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.tag:1.0.0")
.run(assertLiquibase((liquibase) -> assertThat(liquibase.getTag()).isEqualTo("1.0.0")));
}
private ContextConsumer<AssertableApplicationContext> assertLiquibase(Consumer<SpringLiquibase> consumer) {
return (context) -> {
assertThat(context).hasSingleBean(SpringLiquibase.class);

Loading…
Cancel
Save