Flyway conditional db migration
Use the following structure:
└── sql ├── sql_common │ └── V0.0 __.... sql ├── sql_regular │ └── V1.0__create_table_TAB1.sql ├── sql_customer1 │ └── V1.0__create_view_TAB1_to_schema1.sql └── sql_customer2 └── V1.0__create_view_TAB1_to_schema2.sql
in combination with Flyway.setLocations().
- Regular:
flyway.setLocations("filesystem:sql/sql_common","filesystem:sql/sql_regular");
- customer1:
flyway.setLocations("filesystem:sql/sql_common","filesystem:sql/sql_customer1");
- customer2:
flyway.setLocations("filesystem:sql/sql_common","filesystem:sql/sql_customer2");
This way there will be exactly 1 migration with v1.0 per case.