Best way for “database specific” sql scripts with Flyway

You can use the flyway.locations property.

In test in would look like this:

flyway.locations=sql/common,sql/derby

and in prod:

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.

An even better solution, in my opinion, is to have the same DB in prod and test. Yes, you do lose a bit of performance, but on the other hand you also eliminate another difference (and potential source of errors) between the environments.

Leave a Comment