Class FlywayUpgradeUtils


  • public class FlywayUpgradeUtils
    extends Object
    Utility class used to detect issues with the Flyway migration history table and attempt to correct/fix them. These issues can occur when attempting to upgrade your database across multiple versions/releases of Flyway.

    As documented in this issue ticket, Flyway does not normally support skipping over any major release (for example going from v3 to v5 is unsuppored): https://github.com/flyway/flyway/issues/2126

    This class allows us to do a migration (where needed) through multiple major versions of Flyway.

    Author:
    Tim Donohue
    • Method Detail

      • upgradeFlywayTable

        protected static void upgradeFlywayTable​(org.flywaydb.core.Flyway flyway,
                                                 Connection connection)
                                          throws SQLException
        Ensures the Flyway migration history table (FLYWAY_TABLE) is upgraded to the latest version of Flyway safely.

        Unfortunately, Flyway does not always support skipping major versions (e.g. upgrading directly from Flyway v3.x to 5.x is not possible, see https://github.com/flyway/flyway/issues/2126).

        While sometimes it's possible to do so, other times you MUST upgrade through each major version. This method ensures we upgrade the Flyway history table through each version of Flyway where deemed necessary.

        Parameters:
        flyway - initialized/configured Flyway object
        connection - current database connection
        Throws:
        SQLException