0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Flyway】サポート対象のDB Versionなのに「Unsupported Database」エラーが出る問題の解決

Posted at

TL;DR

  • Flyway 10.0以降でflyway-coreからデータベースサポートが分離
  • PostgreSQLを使用する場合はflyway-database-postgresqlの依存関係を追加する必要あり

遭遇した問題

PostgreSQL 14.x(Flywayの公式サポート対象バージョン)を使用しているプロジェクトで、flyway:migrate実行時に以下のエラーが発生:

Unsupported Database: PostgreSQL 14.x

原因

私の場合、以下のように両方のライブラリを指定していたことが問題でした:

dependencies {
    implementation 'org.flywaydb:flyway-core:11.1.1'
    implementation 'org.flywaydb:flyway-database-postgresql:11.1.1'
}

これが問題となった技術的な理由として以下が考えられます:

  • Flyway 10.0からデータベースサポートがflyway-coreから分離されました
  • 両方のライブラリを指定した場合、flyway-coreに含まれる古い(あるいは無効化されているはずの)データベースドライバーが優先的に使用される可能性がある
  • その結果、新しいflyway-database-postgresqlのドライバーが正しく認識されず、「Unsupported Database」エラーが発生する

解決方法

dependencies {
-   implementation 'org.flywaydb:flyway-core:11.1.1'
-   implementation 'org.flywaydb:flyway-database-postgresql:11.1.1'
+   implementation 'org.flywaydb:flyway-database-postgresql:11.1.1'
}

flyway-coreflyway-database-postgresqlの依存関係として自動的に解決されるため、明示的な指定は不要です。

さいごに

メジャーバージョンアップデート時は、依存関係の構造変更の有無を必ず確認しましょう。
特にFlywayの場合、10.0以降は使用するデータベース用の依存関係を明示的に指定する必要があります。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?