Need help with Spring/Flyway configuration. Spring boot Kotlin app has 2 datasources:
@Primary
@Bean("dataSource")
fun dataSource(): DataSource {
return DataSourceBuilder
.create()
.build()
}
@Bean("legacyDataSource")
fun legacyDataSource(): DataSource {
val dataSource = OracleDataSource()
// todo: configure
return dataSource
}
I would like to use Flyway only for dataSource
, not for legacyDataSource
. Usually Flyway should injects flywayInitializer
only for the primary bean, but sometimes it could apply also for legacyDataSource
(eg. when dataSource is disabled in current profile). Does Flyway has an option to disable it per datasource bean? Hints for keys in application.properties
would be very nice ;)
From the doc:
you can use Flyway’s native DataSource by setting spring.flyway.[url,user,password] in external properties. Setting either spring.flyway.url or spring.flyway.user is sufficient to cause Flyway to use its own DataSource. If any of the three properties has not be set, the value of its equivalent spring.datasource property will be used.
So you should fill the above three properties in yaml and thus only the specified datasource will be migrated.