How to disable flyway in a certain spring profile?

Doesn't for for Spring Boot 2.X ! Correct answer is here.

Continue reading if you need an answer for Spring Boot 1.X.

There is a property available for spring-boot to disable flyway if it's needed flyway.enabled which is true by default.

You can have a profile specific configuration, in your case it should be named as application-test.yml. This configuration can disable flyway if profile is active. You just have to declare it as follows:

flyway:
  enabled: false

And if you specify test profile in common configuration, just add it to it's root.


JIC the official documentation with current spring boot 2.x : Data migration properties and take a look on tag # FLYWAY you will find many properties that can help you.

spring.flyway.enabled=false # Whether to enable flyway.

FYI, for anybody who comes here looking for this, the property name has changed for Spring Boot 2.0:

For application.properties format:

spring.flyway.enabled=false

For application.yml format:

spring:
    flyway:
        enabled: false

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. Check out Spring's documentation on Profile-specific properties for more clarity on how to name the files. Generally, the format is application-{profileName}.properties.