Reputation: 1057
I am just starting with flywaydb. Let's consider the case of having 3 databases - PROD, TEST, DEMO.
On each upgrade (and without flywaydb), there are usually a set of sql files that need to be applied to all databases, and some which are environment specific, so one ends up with something like:
PROD: dbUpdateSchema2.0.sql, dbUserSchemaUpdate.sql, dbDataUpdatePROD.sql
DEMO: dbUpdateSchema2.0.sql, dbUserSchemaUpdate.sql, dbDataUpdateDEMO.sql
TEST: dbUpdateSchema2.0.sql, dbUserSchemaUpdate.sql, dbDataUpdateTEST.sql
With flywaydb. how would you recommend these updates to be organised? In particular, how would one share the common sqls (so that you only have one instance of that file and avoid copy-pasting the same sql into different files), whilst then applying environment-specific migrations to each environment?
Upvotes: 1
Views: 1143
Reputation: 987
The documentation is recommending the use of different location if man use different databases, but as in recommendation the analogy applies also just to create different environments:
TEST: flyway.locations=sql/common,sql/test
DEV: flyway.locations=sql/common,sql/dev
PROD: flyway.locations=sql/common,sql/prod
Maybe related with those questions: best-way-for-database-specific-sql-scripts-with-flyway customizing-sql-executed-per-environment
Upvotes: 1