1
0

More than 1 year has passed since last update.

【Flyway】Found more than one migration with versionX.X.Xは、ファイル名が違う場合でも、バージョンが同じだと発生する。

Last updated at Posted at 2022-06-26

エラー内容

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.api.FlywayException: Found more than one migration with version 1.0.0
Offenders:
-> /プロジェクトの配置ディレクトリパス/プロジェクト名/target/classes/db/migration/V1.0.0__users.sql (SQL)
-> /プロジェクトの配置ディレクトリパス/プロジェクト名/target/classes/db/migration/V1.0.0__books.sql (SQL)

エラー原因

マイグレーションのファイルのバージョン衝突が起きていることが原因。
バージョンが同じだと、ファイル名が違う場合でも、エラーが発生する。

ファイル名が違う場合でも、起きるエラーが起きる組み合わせ

  • V1.0.0__users.sql
  • V1.0.0__books.sql

解決方法

バージョン名をそれぞれ、違うものにする。

  • V1.0.0__users.sql
  • V1.0.1__books.sql

なぜ違うファイル名でも、バージョンが同じだと、衝突エラーが起きるの?

Flywayは、バージョンで、マイグレーションの実行順序を決めていて、バージョンが同じだと、どのファイルをどの順序で、実行すればいいか分からなるからです。

1
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
1
0