Skip to content

Commit 8a04e2c

Browse files
committed
Honor custom change log tables in Liquibase endpoint
Closes gh-16442
1 parent 58c9412 commit 8a04e2c

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -87,6 +87,10 @@ private LiquibaseBean createReport(SpringLiquibase liquibase,
8787
if (StringUtils.hasText(defaultSchema)) {
8888
database.setDefaultSchemaName(defaultSchema);
8989
}
90+
database.setDatabaseChangeLogTableName(
91+
liquibase.getDatabaseChangeLogTable());
92+
database.setDatabaseChangeLogLockTableName(
93+
liquibase.getDatabaseChangeLogLockTable());
9094
service.setDatabase(database);
9195
return new LiquibaseBean(service.getRanChangeSets().stream()
9296
.map(ChangeSet::new).collect(Collectors.toList()));

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpointTests.java

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,11 +18,13 @@
1818

1919
import java.sql.Connection;
2020
import java.sql.SQLException;
21+
import java.util.Map;
2122

2223
import javax.sql.DataSource;
2324

2425
import org.junit.Test;
2526

27+
import org.springframework.boot.actuate.liquibase.LiquibaseEndpoint.LiquibaseBean;
2628
import org.springframework.boot.autoconfigure.AutoConfigurations;
2729
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
2830
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
@@ -49,22 +51,40 @@ public class LiquibaseEndpointTests {
4951

5052
@Test
5153
public void liquibaseReportIsReturned() {
52-
this.contextRunner.withUserConfiguration(Config.class)
53-
.run((context) -> assertThat(
54-
context.getBean(LiquibaseEndpoint.class).liquibaseBeans()
55-
.getContexts().get(context.getId()).getLiquibaseBeans())
56-
.hasSize(1));
54+
this.contextRunner.withUserConfiguration(Config.class).run((context) -> {
55+
Map<String, LiquibaseBean> liquibaseBeans = context
56+
.getBean(LiquibaseEndpoint.class).liquibaseBeans().getContexts()
57+
.get(context.getId()).getLiquibaseBeans();
58+
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
59+
});
5760
}
5861

5962
@Test
6063
public void invokeWithCustomSchema() {
6164
this.contextRunner.withUserConfiguration(Config.class)
6265
.withPropertyValues("spring.liquibase.default-schema=CUSTOMSCHEMA",
6366
"spring.datasource.schema=classpath:/db/create-custom-schema.sql")
64-
.run((context) -> assertThat(
65-
context.getBean(LiquibaseEndpoint.class).liquibaseBeans()
66-
.getContexts().get(context.getId()).getLiquibaseBeans())
67-
.hasSize(1));
67+
.run((context) -> {
68+
Map<String, LiquibaseBean> liquibaseBeans = context
69+
.getBean(LiquibaseEndpoint.class).liquibaseBeans()
70+
.getContexts().get(context.getId()).getLiquibaseBeans();
71+
assertThat(liquibaseBeans.get("liquibase").getChangeSets())
72+
.hasSize(1);
73+
});
74+
}
75+
76+
@Test
77+
public void invokeWithCustomTables() {
78+
this.contextRunner.withUserConfiguration(Config.class).withPropertyValues(
79+
"spring.liquibase.database-change-log-lock-table=liquibase_database_changelog_lock",
80+
"spring.liquibase.database-change-log-table=liquibase_database_changelog")
81+
.run((context) -> {
82+
Map<String, LiquibaseBean> liquibaseBeans = context
83+
.getBean(LiquibaseEndpoint.class).liquibaseBeans()
84+
.getContexts().get(context.getId()).getLiquibaseBeans();
85+
assertThat(liquibaseBeans.get("liquibase").getChangeSets())
86+
.hasSize(1);
87+
});
6888
}
6989

7090
@Test

0 commit comments

Comments
 (0)