Commit dade7cc3 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #13625 from 72MiguelGomes:13550/AddSupportSpringLiquibase3.6.2

* pr/13625:
  Polish "Upgrade to Liquibase 3.6.2"
  Upgrade to Liquibase 3.6.2
parents fa171671 4c7c3289
...@@ -126,6 +126,12 @@ public class LiquibaseAutoConfiguration { ...@@ -126,6 +126,12 @@ public class LiquibaseAutoConfiguration {
liquibase.setChangeLog(this.properties.getChangeLog()); liquibase.setChangeLog(this.properties.getChangeLog());
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.setLiquibaseTablespace(this.properties.getLiquibaseTablespace());
liquibase.setDatabaseChangeLogTable(
this.properties.getDatabaseChangeLogTable());
liquibase.setDatabaseChangeLogLockTable(
this.properties.getDatabaseChangeLogLockTable());
liquibase.setDropFirst(this.properties.isDropFirst()); liquibase.setDropFirst(this.properties.isDropFirst());
liquibase.setShouldRun(this.properties.isEnabled()); liquibase.setShouldRun(this.properties.isEnabled());
liquibase.setLabels(this.properties.getLabels()); liquibase.setLabels(this.properties.getLabels());
......
...@@ -53,6 +53,26 @@ public class LiquibaseProperties { ...@@ -53,6 +53,26 @@ public class LiquibaseProperties {
*/ */
private String defaultSchema; private String defaultSchema;
/**
* Schema to use for Liquibase objects.
*/
private String liquibaseSchema;
/**
* Tablespace to use for Liquibase objects.
*/
private String liquibaseTablespace;
/**
* Name of table to use for tracking change history.
*/
private String databaseChangeLogTable;
/**
* Name of table to use for tracking concurrent Liquibase usage.
*/
private String databaseChangeLogLockTable;
/** /**
* Whether to first drop the database schema. * Whether to first drop the database schema.
*/ */
...@@ -132,6 +152,38 @@ public class LiquibaseProperties { ...@@ -132,6 +152,38 @@ public class LiquibaseProperties {
this.defaultSchema = defaultSchema; this.defaultSchema = defaultSchema;
} }
public String getLiquibaseSchema() {
return this.liquibaseSchema;
}
public void setLiquibaseSchema(String liquibaseSchema) {
this.liquibaseSchema = liquibaseSchema;
}
public String getLiquibaseTablespace() {
return this.liquibaseTablespace;
}
public void setLiquibaseTablespace(String liquibaseTablespace) {
this.liquibaseTablespace = liquibaseTablespace;
}
public String getDatabaseChangeLogTable() {
return this.databaseChangeLogTable;
}
public void setDatabaseChangeLogTable(String databaseChangeLogTable) {
this.databaseChangeLogTable = databaseChangeLogTable;
}
public String getDatabaseChangeLogLockTable() {
return this.databaseChangeLogLockTable;
}
public void setDatabaseChangeLogLockTable(String databaseChangeLogLockTable) {
this.databaseChangeLogLockTable = databaseChangeLogLockTable;
}
public boolean isDropFirst() { public boolean isDropFirst() {
return this.dropFirst; return this.dropFirst;
} }
......
...@@ -46,6 +46,7 @@ import org.springframework.boot.testsupport.Assume; ...@@ -46,6 +46,7 @@ import org.springframework.boot.testsupport.Assume;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary; import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.util.ReflectionTestUtils; import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.util.FileCopyUtils; import org.springframework.util.FileCopyUtils;
...@@ -143,6 +144,32 @@ public class LiquibaseAutoConfigurationTests { ...@@ -143,6 +144,32 @@ public class LiquibaseAutoConfigurationTests {
.isEqualTo("public"))); .isEqualTo("public")));
} }
@Test
public void overrideLiquibaseInfrastructure() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
.withPropertyValues("spring.liquibase.liquibase-schema:public",
"spring.liquibase.liquibase-tablespace:infra",
"spring.liquibase.database-change-log-table:LIQUI_LOG",
"spring.liquibase.database-change-log-lock-table:LIQUI_LOCK")
.run((context) -> {
SpringLiquibase liquibase = context.getBean(SpringLiquibase.class);
assertThat(liquibase.getLiquibaseSchema()).isEqualTo("public");
assertThat(liquibase.getLiquibaseTablespace()).isEqualTo("infra");
assertThat(liquibase.getDatabaseChangeLogTable())
.isEqualTo("LIQUI_LOG");
assertThat(liquibase.getDatabaseChangeLogLockTable())
.isEqualTo("LIQUI_LOCK");
JdbcTemplate jdbcTemplate = new JdbcTemplate(
context.getBean(DataSource.class));
assertThat(jdbcTemplate.queryForObject(
"SELECT COUNT(*) FROM public.LIQUI_LOG", Integer.class))
.isEqualTo(1);
assertThat(jdbcTemplate.queryForObject(
"SELECT COUNT(*) FROM public.LIQUI_LOCK", Integer.class))
.isEqualTo(1);
});
}
@Test @Test
public void overrideDropFirst() { public void overrideDropFirst() {
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class) this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
......
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
<kafka.version>1.1.0</kafka.version> <kafka.version>1.1.0</kafka.version>
<kotlin.version>1.2.51</kotlin.version> <kotlin.version>1.2.51</kotlin.version>
<lettuce.version>5.1.0.M1</lettuce.version> <lettuce.version>5.1.0.M1</lettuce.version>
<liquibase.version>3.6.1</liquibase.version> <liquibase.version>3.6.2</liquibase.version>
<log4j2.version>2.11.0</log4j2.version> <log4j2.version>2.11.0</log4j2.version>
<logback.version>1.2.3</logback.version> <logback.version>1.2.3</logback.version>
<lombok.version>1.18.0</lombok.version> <lombok.version>1.18.0</lombok.version>
......
...@@ -566,6 +566,10 @@ content into your application. Rather, pick only the properties that you need. ...@@ -566,6 +566,10 @@ content into your application. Rather, pick only the properties that you need.
spring.liquibase.check-change-log-location=true # Whether to check that the change log location exists. spring.liquibase.check-change-log-location=true # Whether to check that the change log location exists.
spring.liquibase.contexts= # Comma-separated list of runtime contexts to use. spring.liquibase.contexts= # Comma-separated list of runtime contexts to use.
spring.liquibase.default-schema= # Default database schema. spring.liquibase.default-schema= # Default database schema.
spring.liquibase.liquibase-schema= # Schema to use for Liquibase objects.
spring.liquibase.liquibase-tablespace= # Tablespace to use for Liquibase objects.
spring.liquibase.database-change-log-table= # Name of table to use for tracking change history.
spring.liquibase.database-change-log-lock-table= # Name of table to use for tracking concurrent Liquibase usage.
spring.liquibase.drop-first=false # Whether to first drop the database schema. spring.liquibase.drop-first=false # Whether to first drop the database schema.
spring.liquibase.enabled=true # Whether to enable Liquibase support. spring.liquibase.enabled=true # Whether to enable Liquibase support.
spring.liquibase.labels= # Comma-separated list of runtime labels to use. spring.liquibase.labels= # Comma-separated list of runtime labels to use.
......
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