'How do execute ALTER TABLE <table> OWNER to <user> in H2 (with Spring Boot) for Postgresql?

I have a Spring Boot application with an Aurora (Postgresql) DB that I would like to add JPA tests for. We have Flyway setup and our DDL scripts are in a folder in src/main/resources/....

I hooked up H2, but I'm getting a syntax error with ALTER TABLE. It looks like H2 doesn't have the ALTER TABLE <table> OWNER to <user> command.

Has anyone seen this before or know a clever way to get around this?

Exception

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "ALTER TABLE <table> [*]OWNER to <user>"; expected "ADD, SET, RENAME, DROP, ALTER"; SQL statement:
ALTER TABLE <table> OWNER to <user> [42001-212]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:502)


Solution 1:[1]

The SQL is different between these 2 DBMS. You can separate them by different executing path via: (assume you are using liquibase script)

<changeSet id="pg-***"  dbms="postgresql">
    content
</changeSet>

<changeSet id="h2-***" dbms="h2">
    content
</changeSet>

If you are using Some other 3rdparty libs to populate, I believe there is similar way to separate them.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 SeanH