Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable flyway in a certain spring profile?

Now I have a spring-boot app which uses MsSQL server. And we use flyway for migrations.

I want to add an additional profile for tests. I want to generate tables from entity classes instead of using flyway.

I tried smth to write like this in application.yaml

spring:   profiles: test   jpa:       generate-ddl: true       hibernate:   datasource:     url: jdbc:h2:mem:test_db;MODE=MSSQLServer     username: sa     password: 

but flyway starts anyway

like image 258
gstackoverflow Avatar asked May 31 '17 14:05

gstackoverflow


People also ask

What is flyway in spring?

Flyway is a tool that lets you version control incremental changes to your database so that you can migrate it to a new version easily and confidently. In this article, you'll learn how to use Flyway in Spring Boot applications to manage changes to your database.


1 Answers

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.

like image 146
Todd Avatar answered Sep 21 '22 15:09

Todd