Anubhaw Anubhaw - 1 year ago 112
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download