Commit 8a04e2cc authored by Andy Wilkinson's avatar Andy Wilkinson

Honor custom change log tables in Liquibase endpoint

Closes gh-16442
parent 58c9412c
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -87,6 +87,10 @@ public class LiquibaseEndpoint { ...@@ -87,6 +87,10 @@ public class LiquibaseEndpoint {
if (StringUtils.hasText(defaultSchema)) { if (StringUtils.hasText(defaultSchema)) {
database.setDefaultSchemaName(defaultSchema); database.setDefaultSchemaName(defaultSchema);
} }
database.setDatabaseChangeLogTableName(
liquibase.getDatabaseChangeLogTable());
database.setDatabaseChangeLogLockTableName(
liquibase.getDatabaseChangeLogLockTable());
service.setDatabase(database); service.setDatabase(database);
return new LiquibaseBean(service.getRanChangeSets().stream() return new LiquibaseBean(service.getRanChangeSets().stream()
.map(ChangeSet::new).collect(Collectors.toList())); .map(ChangeSet::new).collect(Collectors.toList()));
......
/* /*
* Copyright 2012-2018 the original author or authors. * Copyright 2012-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -18,11 +18,13 @@ package org.springframework.boot.actuate.liquibase; ...@@ -18,11 +18,13 @@ package org.springframework.boot.actuate.liquibase;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Map;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.junit.Test; import org.junit.Test;
import org.springframework.boot.actuate.liquibase.LiquibaseEndpoint.LiquibaseBean;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration; import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
...@@ -49,11 +51,12 @@ public class LiquibaseEndpointTests { ...@@ -49,11 +51,12 @@ public class LiquibaseEndpointTests {
@Test @Test
public void liquibaseReportIsReturned() { public void liquibaseReportIsReturned() {
this.contextRunner.withUserConfiguration(Config.class) this.contextRunner.withUserConfiguration(Config.class).run((context) -> {
.run((context) -> assertThat( Map<String, LiquibaseBean> liquibaseBeans = context
context.getBean(LiquibaseEndpoint.class).liquibaseBeans() .getBean(LiquibaseEndpoint.class).liquibaseBeans().getContexts()
.getContexts().get(context.getId()).getLiquibaseBeans()) .get(context.getId()).getLiquibaseBeans();
.hasSize(1)); assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
});
} }
@Test @Test
...@@ -61,10 +64,27 @@ public class LiquibaseEndpointTests { ...@@ -61,10 +64,27 @@ public class LiquibaseEndpointTests {
this.contextRunner.withUserConfiguration(Config.class) this.contextRunner.withUserConfiguration(Config.class)
.withPropertyValues("spring.liquibase.default-schema=CUSTOMSCHEMA", .withPropertyValues("spring.liquibase.default-schema=CUSTOMSCHEMA",
"spring.datasource.schema=classpath:/db/create-custom-schema.sql") "spring.datasource.schema=classpath:/db/create-custom-schema.sql")
.run((context) -> assertThat( .run((context) -> {
context.getBean(LiquibaseEndpoint.class).liquibaseBeans() Map<String, LiquibaseBean> liquibaseBeans = context
.getContexts().get(context.getId()).getLiquibaseBeans()) .getBean(LiquibaseEndpoint.class).liquibaseBeans()
.hasSize(1)); .getContexts().get(context.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets())
.hasSize(1);
});
}
@Test
public void invokeWithCustomTables() {
this.contextRunner.withUserConfiguration(Config.class).withPropertyValues(
"spring.liquibase.database-change-log-lock-table=liquibase_database_changelog_lock",
"spring.liquibase.database-change-log-table=liquibase_database_changelog")
.run((context) -> {
Map<String, LiquibaseBean> liquibaseBeans = context
.getBean(LiquibaseEndpoint.class).liquibaseBeans()
.getContexts().get(context.getId()).getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets())
.hasSize(1);
});
} }
@Test @Test
......
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