Tip on migration to Spring Boot 2 when using Flyway

Posted at — Aug 30, 2018

Spring Boot 1.5.x uses Flyway 3 while Spring Boot 2.x uses Flyway 5. According to the official migration guide for Spring Boot 2, you need to do 2 releases to be able to migrate an application from Spring Boot 1 to Spring Boot 2 if you are using Flyway:

  • First upgrade your 1.5.x Spring Boot application to Flyway 4 (4.2.0 at the time of writing), see the instructions for Maven and Gradle.

  • Once your schema has been upgraded to Flyway 4, upgrade to Spring Boot 2 and run the migration again to port your application to Flyway 5.

While this certainly works, it might not always be convenient to do 2 releases. If you don’t want to do this, follow these steps as a workaround (Assuming you have access to the database):

  1. Migrate your Spring Boot application to Spring Boot 2 and release it so it can be deployed after running the following steps.

  2. Download the command line zip file of Flyway 4.2.0 from https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/4.2.0/

  3. Extract the zip file

  4. Copy the jar file of your 1.5.x Spring Boot application (NOT your Spring Boot 2 version!) to <flyway-path>/jars. NOTE: You need to copy the .original jar file that is generated by Maven or Gradle, if you use the repackage feature. Don’t forget to rename it to end in .jar after copying, otherwise Flyway will not find it

  5. Edit <flyway-path>/conf/flyway.conf:

    • Set 'flyway.url' to the value of 'spring.datasource.url' of the Spring Boot application

    • Set 'flyway.locations' to the value also used in the Spring Boot application

  6. Run ./flyway migrate

  7. Run ./flyway repair

After this, upgrade the server to use your Spring Boot 2 migrated application.


If you want to be notified in the future about new articles, as well as other interesting things I'm working on, join my mailing list!
I send emails quite infrequently, and will never share your email address with anyone else.