'Problem with h2 creating schema and using it as default for liquibase

hopefully you can help me. I feel like this should be kind of standard stuff, but I can't get it working

so basic setup is: spring + Liquibase + h2

I have a liquibase config:

spring:
  liquibase:
    enabled: true
    url: jdbc:h2:mem:funds;DB_CLOSE_DELAY=-1;INIT=create schema if not exists my_schema
    user: some_user
    password: some_pw
    default_schema: my_schema

which works fine. Now I got some sql that I wanted liquibase to be executed update some_table set field = data (just an example, i have more complicated stuff with joins etc, but the result is the same)

This sadly fails, because it says it can't find the table, which exists. After looking for a bit, prefixing the tablename with the schema makes it work (e.g. update my_schema.some_table set field = data).

What I want though, is that the script works without the schema prefixing.

thus i tried another connection string, adding the default schema in there

spring:
  liquibase:
    url: jdbc:h2:mem:funds;DB_CLOSE_DELAY=-1;INIT=create schema if not exists my_schema;SCHEMA=my_schema

sadly, then liquibase itself throws a JdbcSQLSyntaxErrorException: Schema "my_schema" not found - thus it seems that liquibase tries to connect to the schema itself and the init part from the jdbc url is completely ignored.

My third try was then to use preliquibase with this script "h2.sql" in the preliquibase folder and an url string without the init and schema part:

create schema if not exists my_schema;
set schema my_schema;

sadly running into the same problem from my first try, where the table isn't found unless I prefix it with the schema name.

any ideas ? thanks for any help or insights :)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source