michf
michf

Reputation: 239

Spring boot - h2 and Oracle no 100% compatibility

I am using H2 in Spring boot app and Oracle DB on production. For checking migration files I use FlyWay. Unfortunately, H2 isn't compatible with Oracle (even if is set Oracle mode). So, I can't validate my migrations files. When I have a H2 query - validation in my project is ok, but when I upload it to production - it won`t work on Oracle. Have you got any ideas how can I validate oracle migration files on my h2-db project?

Upvotes: 0

Views: 1509

Answers (1)

Hamish Carpenter
Hamish Carpenter

Reputation: 851

The Flyway FAQ covers this under db specific SQL:

You can use the flyway.locations property. It would look like this:

   TEST (Derby): flyway.locations=sql/common,sql/derby
   PROD (Oracle): flyway.locations=sql/common,sql/oracle

You could then have the common statements (V1__Create_table.sql) in common and different copies of the DB-specific statements (V2__Alter_table.sql) in the db-specific locations.

Another approach if the differences are really minor ie only a few keywords, would be to have the keywords that differ as Flyway placeholders:

ALTER TABLE table_name ${alter_column} COLUMN column_name datatype;

TEST (H2):     flyway.placeholders.alter_column=ALTER
PROD (Oracle): flyway.placeholders.alter_column=MODIFY

Upvotes: 2

Related Questions