Anubhaw Anubhaw - 6 months ago 59
Groovy Question

Flyway's support for Groovy-migrations & conditional environment-specific data insertions

We are working on a Grails-project, and exploring Flyway as a db-migration tool for us.

In our current architecture, we rely on Groovy-migration scripts (executed at application-startup) for conditional environment-specific data insertions (say 'some-data' in 'tableA' for Production against 'other-data' in the same table 'tableA' for pre-Production).

Q1. Does Flyway support Groovy-migration scripts?

Q2. If not, then how best can we achieve conditional environment-specific data insertions?


Q1: Java-based migrations are loaded as binary classes at runtime. Whether the source was Java or Groovy shouldn't matter here. So yes, writing them in Groovy should work.

Q2: Flyway supports multiple locations to load migrations from. These locations can then be configured differently per environment (in your case for PROD & PRE-PROD). You can use this to include different data based on the environment Flyway runs in.