I have noticed that when Liquibase runs a changeset through the maven goal, that is using a native sql-tag, the configured db-schema is ignored. So for example I have configured the maven plugin of Liquibase in the pom to use defaultSchemaName = testSchema, it is applied for all changeset statements that have been defined with the standard xml tags.
An exception to that rule seems to be the native sql part: It tries to use the connection’s default db schema. So in my case a create table Foo(…) is created as testSchema.Foo if I use the Liquibase xml tags, but created as defaultSchema.Foo whenever the same statement is formulated as a native sql tag.
I know that in most cases you can hardcode the name of the schema in the native sql part. In my case I need a more flexible approach, so I introduced a variable for the schema that is set by maven. But isn’t there a way to convince Liquibase to always use the configured schema?
For raw tags, liquibase should just pass the given string through to the connection, I don’t think there is a way to tell it to change the SQL automatically based on a default schema if the connection isn’t following it.