quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Quarkus 2.7 breaks Flyway with MariaDB. #23474

Closed michael-simons closed 2 years ago

michael-simons commented 2 years ago

Describe the bug

When using the official Quarkus Flyway extension together with Quarkus JDBC Maria DB, tests using devservices will fail with:

Caused by: org.flywaydb.core.api.FlywayException: Unsupported Database: MariaDB 10.5
    at org.flywaydb.core.internal.database.DatabaseTypeRegister.getDatabaseTypeForConnection(DatabaseTypeRegister.java:106)

That used to worked in 2.6.x.

Expected behavior

Migrations should be applied.

Actual behavior

Flyway fails, see above.

How to Reproduce?

Have some migration and configure migrate on startup

quarkus.datasource.db-kind=mariadb

quarkus.flyway.migrate-at-start=true

required dependencies

<dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-flyway</artifactId>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-jdbc-mariadb</artifactId>
        </dependency>

Reproducer is attached: demo.zip

Output of uname -a or ver

No response

Output of java -version

java version "11.0.7" 2020-04-14 LTS

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.7.0

Build tool (ie. output of mvnw --version or gradlew --version)

Maven

Additional information

Another reproducer (where i discovered the actual issue)

https://github.com/michael-simons/scrobbles4j/runs/5090741197?check_suite_focus=true#step:5:704

quarkus-bot[bot] commented 2 years ago

/cc @cristhiank, @gastaldi, @geoand, @gsmet

michael-simons commented 2 years ago

Additional information

I suspect it to be related to the class loader changes in Quarkus 2.7 as Flyways seems to do it's detecting via class and or service loader, too: https://github.com/flyway/flyway/issues/3168#issuecomment-839561798

geoand commented 2 years ago

Thanks for reporting!

It turns out that isn't a Quarkus issue, it's due to Flyway moving MySQL code to a different module (done here).

If you add

<dependency>
    <groupId>org.flywaydb</groupId>
    <artifactId>flyway-mysql</artifactId>
</dependency>

to your pom.xml, everything works as expected.

michael-simons commented 2 years ago

Yikes. Thanks for the heads up, I am sure that will hit in another couple of places, too.

It's a bit sad (and absolutely not Quarkus' fault), but there goes the database agnostic build.

Anyhow, I can confirm, this fixes the issue.

geoand commented 2 years ago

Thanks for the heads up

YW!

It's a bit sad (and absolutely not Quarkus' fault), but there goes the database agnostic build.

Yeah, it seems a like a weird move...

gsmet commented 2 years ago

FWIW, it's documented in the migration guide: https://github.com/quarkusio/quarkus/wiki/Migration-Guide-2.7#flyway .

And they did the same for SQL Server in the previous version (which was included in 2.6).

IIUC, they did it to fix license issues but I don't know the specifics.

michael-simons commented 2 years ago

Thanks, @gsmet I should have read this.