Flyway not connecting to the embedded postgress database

45 Views Asked by At

I have a existing working spring boot application with flyway for data migration but now i am trying to configure the application to connect to 2 different data source. I also have a embedded postgress database configured for running test and also some flyway scripts which run during those tests. The flyway test scripts are in src/test/resources/db/migration folder. After doing the configuration connecting the application to 2 different datasources my application is working fine but the tests keep on failing bcoz of the scripts in the flyway src/test/resources folder which were supposed to run on the embedded postgress are now getting executed on the datasources tagged with @primary in the configuration instead of the embedded data source.

I have done the configuration for 2 data source similar to this article https://medium.com/@joeclever/using-multiple-datasources-with-spring-boot-and-spring-data-6430b00c02e7 Also i have tried to configure the flyway migration manually using the flyway.configure().setDataSource() method in a @postconstruct to set that to the embedded data source but this is also not working.

0

There are 0 best solutions below