Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Flyway on Spring Boot 2

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.

like image 522
renke Avatar asked Apr 12 '18 18:04

renke


People also ask

How do I disable Flyway configuration?

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 .

How do you skip Flyway migration?

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.


2 Answers

Add

spring.flyway.enabled=false

To application.properies

like image 186
Alex Avatar answered Sep 28 '22 11:09

Alex


It's because you have jpa.hibernate.ddl-auto set to create. Set it to none instead. Otherwise, flyway.enabled has no effect.

like image 27
Mac Avatar answered Sep 28 '22 12:09

Mac