Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Flyway to load data conditionally per environment

Tags:

Does flyway support conditional execution of a script, per environment?

For example, if I have test data, can I create a test data script folder thats only loaded if the env is configured as test?

like image 671
fansonly Avatar asked Jan 12 '15 19:01

fansonly


People also ask

Does Flyway support multiple schemas?

To create multiple identical schemas you have to invoke Flyway once for each schema, with the flyway. schemas property set the to correct value. Flyway will then set the correct schema as the default one, letting you run your migration scripts unchanged (as long as you don't prefix the object names).

Does Flyway support multiple databases?

During development you need a fast, automated way to build multiple copies of a database on any development or test server, with each database at the right version.

Which is better Flyway or Liquibase?

While both tools are based on Martin Fowler's Evolutionary Database, there are many differences in what these tools offer. Here's where Liquibase and Flyway differ. The bottom line is that Liquibase is more powerful and flexible — covering more database change and deployment use cases than Flyway.

Does Flyway automatically create schema?

If not specified in schemas, Flyway will automatically attempt to create and clean this schema first. This schema will also be the default for the database connection (provided the database supports this concept).


1 Answers

For future visitors, this is a solution for DB specific sql, but applies to data loading too. https://flywaydb.org/documentation/faq#db-specific-sql

You can set the flyway.locations=sql/common,sql/data property, and this can be set to different values with spring profiles(dev/test/prod), omitting the sql/data scripts on production.

like image 55
Busata Avatar answered Sep 18 '22 14:09

Busata