Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Flyway 'baselineOnMigrate' and 'baselineVersion' using spring boot property file

Spring Boot's FlywayProperties.java supports many of the Flyway settings but not 'baselineVersion' or 'baselineOnMigrate'. I am converting an existing application to Flyway and these setting appear to be designed for this purpose. Our production environment is highly controlled and running a commandline version of flyway there to achieve this is not practical.

Is creating a custom Flyway @Bean the only option here?

like image 418
dropofahat Avatar asked Oct 09 '15 03:10

dropofahat


People also ask

How do you implement a Flyway in a spring boot?

Configuring Flyway Database gradle file. In application properties, we need to configure the database properties for creating a DataSource and also flyway properties we need to configure in application properties. For properties file users, add the below properties in the application. properties file.

What is Baselineversion in Flyway?

Description. The version to tag an existing schema with when executing baseline.


1 Answers

You can set any of flyways properties be prefixing them with flyway in your application.yml/.properties.

It is made possible by org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration.FlywayConfiguration#flyway which is annotated with @ConfigurationProperties(prefix = "flyway").

If you are using an application.yml add the following:

flyway:
    baselineOnMigrate: true

If using an application.properties add the following:

flyway.baselineOnMigrate = true
like image 55
Marco Schulte Avatar answered Oct 21 '22 01:10

Marco Schulte