question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sqlFile no longer has default schema set

See original GitHub issue

Environment

Liquibase Version: Issue first reproducible with 4.5.0; confirmed to still exist in 4.6.1.

Liquibase Integration & Version: Spring Boot

Liquibase Extension(s) & Version: n/a

Database Vendor & Version: Postgresql 11

Operating System Type & Version: Linux / Fedora 35

Description

In Liquibase 4.5.0, the behavior of sqlFile changed. In Liquibase <= 4.5.0, the current schema for the sql is set to the configured Liquibase default schema. Starting with commit https://github.com/liquibase/liquibase/pull/1864/commits/411f77a63c4a4c637f3f68556a6bebf53b549754 the schema is not changed, so the sql executes using the jdbc connection’s default schema.

Steps To Reproduce

Before Liquibase 4.5.0, this changeset xml would create tables in the liquibase configured default schema (ex, if spring.liquibase.default-schema: example_db, then the tables would be in the example_db schema):

<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
                      http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.6.xsd">
  <changeSet id="spring-session" author="me">
       <sqlFile path="org/springframework/session/jdbc/schema-postgresql.sql" dbms="postgresql" />
  </changeSet>

org/springframework/session/jdbc/schema-postgresql.sql for reference.

Starting with Liquibase 4.5.0, specifically starting with commit https://github.com/liquibase/liquibase/pull/1864/commits/411f77a63c4a4c637f3f68556a6bebf53b549754 , that xml will create tables in a different schema. For example, on postgres, it will probably create them in the public schema.

Actual Behavior

sqlFile sql is executed with the current schema set to the jdbc connection’s default schema.

Expected/Desired Behavior

sqlFile sql is executed with the current schema set to the Liquibase configured default schema.

Screenshots (if appropriate)

n/a

Additional Context

This regression was introduced in https://github.com/liquibase/liquibase/pull/1864

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
nvoxlandcommented, Apr 29, 2022

I created a PR that should address this

3reactions
phbenisccommented, Mar 9, 2022

Also a related problem: Schema based multi Tenancy based on MultiTenantSpringLiquibase seems also to be broken. I think it is because it configures the default schema via liquibase and not via the jdbc. Happend to me with a postgresql 13.

The workaround seems also to work with multi tenancy, but suffers from the same problem with the checksum.

Also latest working version is at the moment seems to be 4.4.3. But projects that are stuck on this version should be aware of the following security vulnerability:

CVE-2022-0839 < 4.8.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Liquibase: how to configure sqlFile tag so it can be executed ...
Many tags of liquibase seem to have the property "schemaName", but the sqlFile (or the sql) tag does not... liquibase.
Read more >
Setting current database schema
Running an .sql file generated by mysqldump, I can select the data ... However, there's no obvious option to select the desired schema....
Read more >
how to create a schema for defaultSchemaName
Hi Team, As of now, I am creating database schema through some script in oracle. But I want to create db schema through...
Read more >
Quick Guide on Loading Initial Data with Spring Boot - Baeldung
Spring Boot internally defaults this parameter value to create-drop if no schema manager has been detected, otherwise none for all other cases. We...
Read more >
sqlFile | Liquibase Docs
Reference information for the sqlFile change type. The sqlFile change type allows you to specify any sql statements and have it stored external...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found