Our Spring Boot application uses Liquibase for database migration upon deployment.
Our production system uses an SAP HANA database, while for local testing, we're using H2.
Due to various problems we want to migrate from H2 v1.4.x to H2 v2, but the problem is that some column and table identifiers we used in our Liquibase changesets are reserved words in H2 v2.x (but not in SAP HANA) and lead to SQL syntax errors when testing locally.
Adapting the changeset files is not an option since that would change their checksum and lead to liquibase errors when the application is deployed.
Is there a global flag that can be set outside the changeset files which forces Liquibase to double-quote all identifiers when generating the SQL statements?
What I've tried so far:
- objectQuotingStrategy: QUOTE_ALL_OBJECTS into the master changelog file from which the individual changesets are included.parameter.objectQuotingStrategy=QUOTE_ALL_OBJECTS into liquibase.properties.objectQuotingStrategy to QUOTE_ALL_OBJECTS programmatically upon instantiation of the SpringLiquibase bean.Those settings don't seem to do anything in that respect.
I managed to find a viable solution.
Actually objectQuotingStrategy would be the way to go as intended by the Liquibase developers but due to a high-priority bug in Liquibase that has been open since 2017, this does not work for H2 databases.
However I was able to work around the problem by exempting some reserved words through the DB connection string:
jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;NON_KEYWORDS=DAY,VALUE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With