Honor custom change log tables in Liquibase endpoint
Closes gh-16442
This commit is contained in:
parent
58c9412c09
commit
8a04e2cc86
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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 {
|
||||||
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()));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* 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;
|
||||||
|
|
||||||
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 {
|
||||||
|
|
||||||
@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 {
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue