I've been trying to disable Flyway for my unit tests on Spring Boot 2, but could not succeed.
I understand, from Spring Boot's documentation, that the property for doing so changed from flyway.enabled
to spring.flyway.enabled
, and added that to my test application profile (as below).
spring:
datasource:
url: jdbc:h2:mem:db
jpa:
hibernate:
ddl-auto: create
flyway:
enabled: false
This configuration appears to have no effect at all, and Flyway auto-configuration is still invoked.
I also tried creating a separate auto-configuration class for the unit tests only, where I added @EnableAutoConfiguration(exclude = FlywayAutoConfiguration.class)
, but this try failed as much as the previous one.
Update: To disable flyway in a specific profile, you can put that property in the properties file specific to that profile. For instance, if your profile is called "abc", you can put it in application-abc. properties .
The hotfix migration can be deployed with Flyway with skipExecutingMigrations=true . The schema history table will be updated with the new migration, but the script itself won't be executed again. skipExecutingMigrations can be used with with cherryPick to skip specific migrations.
Add
spring.flyway.enabled=false
To application.properies
It's because you have jpa.hibernate.ddl-auto set to create
. Set it to none
instead. Otherwise, flyway.enabled has no effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With