score:1

Accepted answer

define a second flyway bean. then add to both flyway beans a different sqlmigrationprefix property and name your migration scripts accordingly.

for example

<bean class="com.googlecode.flyway.core.flyway" init-method="migrate">
   <property name="datasource" ref="datasource1" />
   <property name="sqlmigrationprefix" value="db1_" />
</bean>
<bean class="com.googlecode.flyway.core.flyway" init-method="migrate">
   <property name="datasource" ref="datasource2" />
   <property name="sqlmigrationprefix" value="db2_" />
</bean>

your migration scripts have to follow this naming scheme:

db1_1.0__initial_setup.sql
db1_1.1__new_column.sql

db2_1.0__initial_setup.sql
db2_1.1__new_column.sql

edit - configuration by code:

in your code you are having two flyway instances. this instances are equivalent to the definition as a spring bean. so you can call the following to achieve the same:

flyway.setsqlmigrationprefix("db1_");
flywaygen.setsqlmigrationprefix("db2_");

Related Query

More Query from same tag