Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
* {@link Endpoint @Endpoint} to expose liquibase info.
*
* @author Eddú Meléndez
* @author Nabil Fawwaz Elqayyim
* @since 4.0.0
*/
@Endpoint(id = "liquibase")
Expand Down Expand Up @@ -80,9 +81,12 @@ private LiquibaseBeanDescriptor createReport(SpringLiquibase liquibase, Database
Database database = null;
try {
database = factory.findCorrectDatabaseImplementation(connection);
String defaultSchema = liquibase.getDefaultSchema();
if (StringUtils.hasText(defaultSchema)) {
database.setDefaultSchemaName(defaultSchema);
String schemaToUse = liquibase.getLiquibaseSchema();
if (!StringUtils.hasText(schemaToUse)) { // Use liquibase-schema if set, otherwise fall back to default-schema
schemaToUse = liquibase.getDefaultSchema();
}
if (StringUtils.hasText(schemaToUse)) {
database.setDefaultSchemaName(schemaToUse);
}
database.setDatabaseChangeLogTableName(liquibase.getDatabaseChangeLogTable());
database.setDatabaseChangeLogLockTableName(liquibase.getDatabaseChangeLogLockTable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
* @author Andy Wilkinson
* @author Stephane Nicoll
* @author Leo Li
* @author Nabil Fawwaz Elqayyim
*/
@WithResource(name = "db/changelog/db.changelog-master.yaml", content = """
databaseChangeLog:
Expand Down Expand Up @@ -120,6 +121,21 @@ void invokeWithCustomTables() {
});
}

@Test
@WithResource(name = "db/create-custom-schema.sql", content = "CREATE SCHEMA LIQUIBASE_SCHEMA;")
void invokeWithLiquibaseSchema() {
this.contextRunner.withUserConfiguration(Config.class, DataSourceWithSchemaConfiguration.class)
.withPropertyValues("spring.liquibase.liquibase-schema=LIQUIBASE_SCHEMA")
.run((context) -> {
Map<String, LiquibaseBeanDescriptor> liquibaseBeans = context.getBean(LiquibaseEndpoint.class)
.liquibaseBeans()
.getContexts()
.get(context.getId())
.getLiquibaseBeans();
assertThat(liquibaseBeans.get("liquibase").getChangeSets()).hasSize(1);
});
}

@Test
void connectionAutoCommitPropertyIsReset() {
this.contextRunner.withUserConfiguration(Config.class).run((context) -> {
Expand Down