Stuzfuz
Stuzfuz

Reputation: 95

Flyway detects an incompatible MySQL version even though the documentation says it is compatible

I've updated Spring Boot to version 3.0.1 and to also tried to update Flyway to version 9.10.1.

...
dependencies {
    // Spring
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    implementation("org.springframework.boot:spring-boot-starter-jooq")
    implementation("org.springframework.boot:spring-boot-starter-mail")
    implementation("org.springframework.boot:spring-boot-starter-web")
    implementation("org.springframework.security:spring-security-oauth2-resource-server")
    implementation("org.springframework.security:spring-security-oauth2-jose")
    implementation("org.springframework.security:spring-security-config")

    // Jooq
    implementation("org.jooq:jooq:3.17.6")
    implementation("org.jooq:jooq-meta:3.17.6")
    implementation("org.jooq:jooq-codegen:3.17.6")
    jooqGenerator("mysql:mysql-connector-java:8.0.31")
    jooqGenerator('jakarta.xml.bind:jakarta.xml.bind-api:4.0.0')

    // Flyway
    implementation('org.flywaydb:flyway-core:9.10.1')
}
...

Without the Flyway dependency my application is starting and working as expected. But with Flyway enabled the application keeps crashing and stating that the db version is not supported:

Caused by: org.flywaydb.core.api.FlywayException: Unsupported Database: MySQL 8.0
    at org.flywaydb.core.internal.database.DatabaseTypeRegister.getDatabaseTypeForConnection(DatabaseTypeRegister.java:106) ~[flyway-core-8.5.13.jar:na]

But the official documentation states that MySQL 8.0 is supported: https://documentation.red-gate.com/fd/mysql-184127601.html

Any help is appreciated.

Upvotes: 3

Views: 1895

Answers (2)

Amir Azizkhani
Amir Azizkhani

Reputation: 1813

Sometimes in very old version you can not find any suitable version to easily fix your problem. So if you stuck between FlywayAutoConfiguration and your flyway-core version that can support your db, and you need to upgrade your Spring boot version, The only way for you, is replacement old FlywayAutoConfiguration compatible with your supported db and flyway with new version that exists in current upgraded spring boot.

For me, I excluded (@EnableAutoConfiguration(exclude = {FlywayAutoConfiguration.class})) flyway class in latest spring boot auto configuration, and I added that compatible version that I've worked with it.

see this post for registering your own Auto configuration.

Upvotes: 0

codemonkey
codemonkey

Reputation: 3830

MySQL support was extracted to a separate dependency in Flyway 8.2.1.

It needs to be added as per the Java Usage instructions.

e.g.

dependencies {
    implementation("org.flywaydb:flyway-mysql")
}

Upvotes: 3

Related Questions