1

2つのモジュールを持つプロジェクトがあります。どちらのモジュールも、データベースの移行と初期設定にフライウェイを使用します。どちらのプロジェクトも独立しています。各モジュールでテストも行っています。両方のモジュールを実行する場合、または1つのモジュールから1つのテストのみを実行する場合は常に、移行が実行されない場合があります。モジュール1には

  • abcaccount.persistence.jdbc.migrations.Vaccount_1__CreateStructure.java abcaccount.persistence.jdbc.migrations.Vaccount_2__CreateIndexOnN​​ame.sql ... abcaccount.persistence.jdbc.migrations.Vaccount_5__AddDAOCreatedAndUpdated.sql

およびJDBCAccountPersistenceServiceImplとJDBCAccountPersistenceServiceImplTest。

モジュール2には

  • abcauthentication.persistence.jdbc.migrations.Vauth_1__CreateTableForPasswords.sql abcauthentication.persistence.jdbc.JDBCAuthenticationPersistenceServiceImpl

およびJDBCAuthenticationPersistenceServiceImplTest。

両方のImplは、そのinitメソッドの呼び出しを親クラスと共有します。

//prepare db.
Flyway flyway = new Flyway();
flyway.setDataSource(getDataSource());
flyway.setLocations(getClass().getPackage().getName()+".migrations");
flyway.migrate();

クリーンデータベースとフィルドデータベースで別々に開始した場合、両方のテストが機能します。ただし、DBをクリーンアップし、最初にJDBCAuthenticationPersistenceServiceImplTestを実行してintellijからテストを実行すると、他のテストは失敗します。

org.postgresql.util.PSQLException: ERROR: relation "account" does not exist
  Position: 13
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)

この場合、schema_versionには次の1行しか含まれません。

1 |              1 | auth.1  | CreateTableForPasswords | SQL  | Vauth_1__CreateTableForPasswords.sql | -1961897674 | another      | 2013-01-14 23:39:00.736033 |             18 | t

すべてのテーブルを手動で削除すると、テストが再度実行されます。クリーンデータベース(maven)のコンソールからテストを実行すると、それも機能します。私は何が間違っているのですか?auth.1がaccount.1よりも高いバージョンと見なされているため、account.1パッチが実行されていない可能性がありますか?

4

1 に答える 1

0

ここで手元にある3つの問題。

  1. Vaccount_のようなsqlMigrationPrefixがありません
  2. Flywayはバージョンに対して過度に寛容であり、有効なバージョン番号としてaccount.1を拒否する必要があります
  3. モジュールには、おそらく個別のメタデータテーブルが必要です
于 2013-01-15T09:11:00.230 に答える