Flyway PostgreSQL Support in Spring Boot 3.3.0
Problem: Unsupported Database Error with PostgreSQL 16
After upgrading to Spring Boot 3.3.0, Flyway fails to connect to PostgreSQL 16 databases, throwing the error:
Caused by: org.flywaydb.core.api.FlywayException: Unsupported Database: PostgreSQL 16.2
at org.flywaydb.core.internal.database.DatabaseTypeRegister.getDatabaseTypeForConnection(DatabaseTypeRegister.java:105)
...This occurs due to Flyway's new modular architecture introduced in Flyway 9.x, where database-specific support was moved from the core module to separate dependencies. Spring Boot 3.3.0 includes newer versions of Flyway that require explicit PostgreSQL module declaration.
Solution: Add PostgreSQL Database Module
Primary Fix
Add Flyway's PostgreSQL module to your dependencies:
Maven (pom.xml):
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-database-postgresql</artifactId>
</dependency>Gradle (build.gradle):
implementation 'org.flywaydb:flyway-database-postgresql'Verify Flyway Version
TIP
Spring Boot 3.3.0 manages Flyway versions automatically (flyway-core 10.x). Avoid manual version downgrades unless necessary, as they may cause compatibility issues.
Recommended Configuration
Add standard Flyway configuration to application.yml for full functionality:
spring:
flyway:
enabled: true
locations: classpath:db/migration
baseline-on-migrate: trueWhy This Works
Flyway restructured its architecture in version 9.0, extracting database support into separate modules:
flyway-corenow contains only core functionality- Database-specific implementations require dedicated modules (e.g.,
flyway-database-postgresql) - Spring Boot dependency management automatically resolves compatible versions
Common Pitfalls to Avoid
Downgrading flyway-core
WARNING
Avoid downgrading to unsupported versions:
xml<!-- Do NOT use this workaround --> <version>9.16.3</version>This bypasses the root issue and may cause Spring Boot compatibility problems.
Missing configuration
Ensurebaseline-on-migrate: trueis set if using an existing database schemaIncomplete dependency sets
Theflyway-database-postgresqlmodule must coexist withflyway-core- don't remove the core dependency
Troubleshooting Persistent Issues
If the error persists after adding the PostgreSQL module:
- Verify dependency hierarchy with:bash
mvn dependency:tree - Ensure no conflicting Flyway versions
- Check PostgreSQL JDBC driver version (recommended:
42.7.3or later) - Confirm database version in logs matches your PostgreSQL installation
For enterprise setups or complex environments, see Flyway's official PostgreSQL documentation.
Alternative: Manual Flyway Configuration
Explicitly configure Flyway version when needed:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>10.15.2</version>
</dependency>TIP
Prefer the Spring-managed version unless you have specific integration requirements. The manual version should always pair with the PostgreSQL module dependency.