user1555190
user1555190

Reputation: 3239

Flyway to update two databases

I have micrnaut based java application. which uses two databases, i have set up the two datasources

but how can i use flyway to load different data into the two databases

directory is as follows, which works for single db as following examples:

resources -> db->migration -> V1__data.sql

Upvotes: 1

Views: 775

Answers (1)

Sascha Frinken
Sascha Frinken

Reputation: 3366

Assuming you have two datasources as below:

datasources:
  default: 
    url: 'jdbc:h2:mem:flywayDb1;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE'
    username: 'sa'
    password: ''
    driverClassName: 'org.h2.Driver'
  other: 
    url: 'jdbc:h2:mem:flywayDb2;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE'
    username: 'sa'
    password: ''
    driverClassName: 'org.h2.Driver'

You can configure Flyway as below:

flyway:
  datasources:
    default:
      enabled: true
      locations:
        - classpath:db/migrations/default
    other:
      enabled: true
      locations:
        - classpath:db/migrations/other

Check the micronaut Flyway manual for more information.

Upvotes: 2

Related Questions