public void migrate(Connection connection) throws SQLException {
        try {
            log.info("Upgrading database, this might take a while depending on the size of the database.");

            List<String> messages = List.of(
                    repeat("*", "", 72),
                    "WARNING: Shutting down your server at this point will lead to a database corruption. Please wait until the database upgrade completes.",
                    repeat("*", "", 72)
            );
            for (String message : messages) {
                System.err.println(message);
                log.info(message);
            }

            disableLiquibaseConsoleLogging();

            Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
            newLiquibaseFor(database).update();

            System.err.println("INFO: Database upgrade completed successfully.");
            log.info("Database upgrade completed successfully.");

            DataMigrationRunner.run(connection);
        } catch (LockException e) {
            String message = "Unable to migrate the database, as it is currently locked. A previous GoCD start-up may have been interrupted during migration, and you may need to " +
                "1) validate no GoCD instances are running, " +
                "2) check the DB health looks OK, " +
                "3) unlock by connecting directly to the database and running the command noted at https://docs.liquibase.com/concepts/tracking-tables/databasechangeloglock-table.html, " +
                "4) restarting GoCD.";
            log.error("{} The problem was: [{}] cause: [{}]", message, ExceptionUtils.getMessage(e), ExceptionUtils.getRootCauseMessage(e), e);
            throw new SQLException(message, e);
        } catch (LiquibaseException e) {
            String message = "Unable to migrate the database.";
            log.error("{} The problem was: [{}] cause: [{}]", message, ExceptionUtils.getMessage(e), ExceptionUtils.getRootCauseMessage(e), e);
            throw new SQLException(message, e);
        }
    }
@Test
    public void shouldRaiseWrappedExceptionForOtherErrors() throws Exception {

        try (MockedStatic<DataMigrationRunner> migration = mockStatic(DataMigrationRunner.class); Connection connection = dummyH2Connection()) {
            doThrow(new LiquibaseException("Liquibase error")).when(liquibase).update();

            assertThatThrownBy(() -> migrator.migrate(connection))
                .isExactlyInstanceOf(SQLException.class)
                .hasMessageContaining("Unable to migrate the database")
                .hasRootCauseExactlyInstanceOf(LiquibaseException.class)
                .hasRootCauseMessage("Liquibase error");

            migration.verifyNoInteractions();
        }
    }