Automatically baselining a database with Flyway in a Spring Boot project

Viewed 326

I'm trying to add Flyway to a Spring Boot project. In accordance with the instructions, I've created my initial DDL script and committed it to src/main/resources/db/migration/V1__base_version.sql.

If I run the baseline command, this will create the flyway_schema_history table and set the baseline version therein to 1.

While this works fine for my local database, I would like this to happen automatically on the other developers' local environments, UAT environment, etc.

I tried adding the following property to the Spring Boot config

spring:
  flyway:
    baseline-on-migrate: true

I expected this to do the same thing as the baseline command when the Spring Boot app starts up if the flyway_schema_history table does not exist, i.e. create this table and insert a row specifying the current schema version, but it didn't.

Is there a way to automatically baseline the database when the app starts up?

0 Answers
Related