简体   繁体   中英

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)

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM