flyway: šŸ“¢ Modular Flyway V10 (No database found to handle or Unsupported Database)

It has come to our attention that the move to a more modular Flyway in version V10.0.0 may not have been made clear enough in our release notes.

As we attempt to move towards a much wider range of supported databases and database types we have found ourselves needing to extract database support out from flyway-core and into their own modules in order to improve maintainability and distribution size.

As a result, databases, with the exception of in-memory or file databases such as H2 or SQLite, have been moved into their own packages which need to be added to your project when upgrading to Flyway V10.0.0. This includes whether you are using Flyway as a dependency in your project or using the Gradle or Maven plugins.

The list of additional dependencies can be seen below:

  • org.flywaydb:flyway-database-db2
  • org.flywaydb:flyway-database-derby
  • org.flywaydb:flyway-database-hsqldb
  • org.flywaydb:flyway-database-informix
  • org.flywaydb:flyway-database-postgresql
  • org.flywaydb:flyway-database-oracle
  • org.flywaydb:flyway-database-redshift
  • org.flywaydb:flyway-database-saphana
  • org.flywaydb:flyway-database-snowflake
  • org.flywaydb:flyway-database-sybasease
  • org.flywaydb:flyway-firebird
  • org.flywaydb:flyway-gcp-bigquery
  • org.flywaydb:flyway-gcp-spanner
  • org.flywaydb:flyway-mysql
  • org.flywaydb:flyway-singlestore
  • org.flywaydb:flyway-sqlserver

If you are using any of the databases affected, please include the corresponding dependency in your project.

We are expecting that by structuring Flyway in to purposeful dependencies that we can both give developers more control of what aspects of Flyway they include in their project but also allow us to more fluently accept contributions and desired functionality from our community.

For more information on our on going goal to improve Flyway’s open source version please see the following blog.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 58
  • Comments: 20 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I am still getting this error even after adding in the org.flywaydb:flyway-database-postgresql dependency. Please help:

build.gradle

plugins {
    id 'java'
    id 'org.springframework.boot' version '3.3.0'
    id 'io.spring.dependency-management' version '1.1.5'
    id "org.flywaydb.flyway" version "10.13.0"
}

group = 'com.discoverfinancial'
version = '0.0.1-SNAPSHOT'

java {
    sourceCompatibility = '17'
}

repositories {
    maven { url nexusPublicRepoURL }
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.flywaydb:flyway-core'
    runtimeOnly 'org.flywaydb:flyway-database-postgresql'
    implementation 'org.postgresql:postgresql'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
    useJUnitPlatform()
}

Changing this in my build.gradle has fixed the Unsupported Database error for me:

- org.flywaydb:flyway-core
+ org.flywaydb:flyway-database-postgresql:10.20.1

Hello, adding the dependencies to flyway-mysql and flyway-database-postgresql did not solve the issue in our case.

We’re running Flyway in an AWS Lambda using a JAR created with the maven shade plugin. All the dependencies are in the pom.xml as below (we’re using version 10.11.1). The database type are present when the lambda is running (we can log their class name). Despite all of this, we keep getting No database found to handle jdbc:postgresql: and the MySQL equivalent.

Is there something specific to do for Lambdas?

        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
            <version>${flyway.version}</version>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-database-postgresql</artifactId>
            <version>${flyway.version}</version>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-mysql</artifactId>
            <version>${flyway.version}</version>
        </dependency>

For gradle, you need to follow the documentation. šŸ˜„

The dependency MUST be added inside the buildscript. Example for postgresql:

buildscript {
    dependencies {
        classpath "org.flywaydb:flyway-database-postgresql:10.0.0"
    }
}

Thank you for preemptively opening this issue. I was about to open issue myself when I saw it šŸ™ˆ

I have been struggling all weekend to get Flyway to run/work. I have setup an initial Spring Boot (3.3.3) java (17) application. Initially I was using postgres. But despite using both org.flywaydb:flyway-core and flyway-database-postgresql (10.17.2) my migration did not run. When running ā€œgradlew flywayInfoā€ I get this message.

Error occurred while executing flywayInfo No database found to handle jdbc:mysql://my_host:my_port/my_database

Then today, I gave up and changed to mysql instead. But I got the same problem. Frustrating.

For Flyway versions higher than 10 with Maven Shade, <transformerimplementation=ā€œorg.apache.maven.plugins.shade.resource.ServicesResourceTransformerā€/> is needed because it uses Service Loader and no longer Java reflection. From my Stack Overflow question and answer

It could be cool to update the documentation for common used database (postgresql, mysql…) and with common build tools (gradle, maven), because the current documentation is still on 9.19 šŸ˜….

In my specific case, I’ve tried for gradle build tool, but without success in my module.

I tried to add implementation("org.flywaydb:flyway-database-postgresql:10.0.0") in the dependencies block, but with the same error/result when I run :flywayMigrate task

Additionally, I would like to have this dependency ONLY during task execution. Except if I’m wrong, the flyway plugin doesn’t have a custom dep definition (like the jooq plugin in my example), it means to me I’ll have to carry this dependency in my application… even if I don’t use it !? šŸ¤”.

Created a small spring app from spring

Can’t make it work. Also, tried @Lob2018 SO suggestion but I receive some main error

What I am missing?

https://docs.spring.io/spring-boot/how-to/data-initialization.html#howto.data-initialization.migration-tool.flyway

https://documentation.red-gate.com/flyway/getting-started-with-flyway/system-requirements/supported-databases-and-versions

Caused by: org.flywaydb.core.api.FlywayException: Unsupported Database: PostgreSQL 16.0

properties

spring.application.name=demo
spring.datasource.url=jdbc:postgresql://localhost:5432/omnidb
spring.datasource.username=omni
spring.datasource.password=omni
spring.datasource.driverClassName=org.postgresql.Driver

POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>3.3.3</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>demo</name>
	<description>Demo project for Spring Boot</description>
	<url/>
	<licenses>
		<license/>
	</licenses>
	<developers>
		<developer/>
	</developers>
	<scm>
		<connection/>
		<developerConnection/>
		<tag/>
		<url/>
	</scm>
	<properties>
		<java.version>21</java.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-data-jpa</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flywaydb</groupId>
			<artifactId>flyway-core</artifactId>
		</dependency>
		<dependency>
			<groupId>org.flywaydb</groupId>
			<artifactId>flyway-database-postgresql</artifactId>
		</dependency>

		<dependency>
			<groupId>com.h2database</groupId>
			<artifactId>h2</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<scope>runtime</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.18.30</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>

<!--			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>3.6.0</version>
				<configuration>
					<transformers>
						<transformer
								implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
							<mainClass>fr.bla.Launcher</mainClass>
						</transformer>
						<transformer
								implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
					</transformers>
					<filters>
						<filter>
							<artifact>*:*</artifact>
							<excludes>
								<exclude>META-INF/maven/**</exclude>
								<exclude>META-INF/*.SF</exclude>
								<exclude>META-INF/*.DSA</exclude>
								<exclude>META-INF/*.RSA</exclude>
							</excludes>
						</filter>
					</filters>
				</configuration>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
					</execution>
				</executions>
			</plugin>-->

		</plugins>
	</build>

</project>

EDIT:

By defining explicity jar version, it worked (was not working even with postgres 15.8)

        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
            <version>10.17.3</version>
        </dependency>

        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-database-postgresql</artifactId>
            <version>10.17.3</version>
        </dependency>

@davinkevin thank you for your suggestion, that is something we may look into

I confirm it worked for me, but it’s not a very good pattern for gradle build tool. By doing that, all flyway dependencies leak to the build classpath, for all plugins.

The best solution would be to declare a dedicated configuration used by the plugin and which can be declared by a dedicated element in the dependencies block, like done by the jooq plugin.

It could be like this for flyway, which is better for configuration and good to avoid conflicts between plugin dependencies.

dependencies {
    flyway("org.flywaydb:flyway-database-postgresql:10.0.0")
}

For gradle, you need to follow the documentation. šŸ˜„

The dependency MUST be added inside the buildscript. Example for postgresql:

buildscript {
    dependencies {
        classpath "org.flywaydb:flyway-database-postgresql:10.0.0"
    }
}

Thanks for calling this out! Not sure how I missed it 🤦

@davinkevin this may solve your issue as well. In our case I had to add parens to the snippet as seen below:

buildscript {
    dependencies {
        classpath("org.flywaydb:flyway-database-postgresql:10.0.0")
    }
}

It could be cool to update the documentation for common used database (postgresql, mysql…) and with common build tools (gradle, maven), because the current documentation is still on 9.19 šŸ˜….

In my specific case, I’ve tried for gradle build tool, but without success in my module.

I tried to add implementation("org.flywaydb:flyway-database-postgresql:10.0.0") in the dependencies block, but with the same error/result when I run :flywayMigrate task

Additionally, I would like to have this dependency ONLY during task execution. Except if I’m wrong, the flyway plugin doesn’t have a custom dep definition (like the jooq plugin in my example), it means to me I’ll have to carry this dependency in my application… even if I don’t use it !? šŸ¤”.

This also seems broken for us

No database found to handle jdbc:postgresql://localhost:5432/prime_data_hub

The appropriate dependency has been added:

    implementation("org.flywaydb:flyway-core:10.0.1")
    implementation("org.flywaydb:flyway-database-postgresql:10.0.1")

I noticed this in the release notes:

Notes
Flyway Gradle Plugin is currently unable to be released.

Am I correct in assuming we are waiting for the gradle plugin to be released?