2

Does flyway run different migration scripts as per environment prod/dev?

I have dev data, can I create a dev data script folder that's only loaded if the environment is configured as dev? Because we have different data for dev and for prod, But some scripts are common in both. Can we create a third migration folder for common scripts that can run in both environments. when any profile specific flyway scripts run common scripts also run with that.

  • 1
    Hi & Welcome! You could "bind" (relevant) flyway configuration to spring profiles...like outlined [here](https://stackoverflow.com/q/59532496/592355) – xerx593 Oct 18 '22 at 18:30
  • flyway should manage schema for example add column / add table and so on only for changes which needs to be done for all environments But if you need to load initial data same for each environments flyway is the best. If you need different migrations or data for each enviroment flyway is not good for that. – notAPPP Oct 18 '22 at 19:05

1 Answers1

0

Can create common migration folder and change the application properties file (dev/qa/prod) as bellow.

Spring.flyway.locations : classpath_to_profile_specific_folder , classpath _to_common_folder

Use , to seperate folder paths. Refer this documentation for more info.

By activationg profile you can run both profile specific and common schemas. However have to be careful on schema versions.

YJR
  • 1,099
  • 3
  • 13