HHH-10425 - Fix SchemaMigration creates foreign keys too early if across schema
This commit is contained in:
parent
df362e4568
commit
3fb9577e50
|
@ -183,7 +183,6 @@ public class SchemaMigratorImpl implements SchemaMigrator {
|
|||
|
||||
applyIndexes( table, tableInformation, metadata, targets );
|
||||
applyUniqueKeys( table, tableInformation, metadata, targets );
|
||||
applyForeignKeys( table, tableInformation, metadata, targets );
|
||||
}
|
||||
|
||||
for ( Sequence sequence : namespace.getSequences() ) {
|
||||
|
@ -205,6 +204,17 @@ public class SchemaMigratorImpl implements SchemaMigrator {
|
|||
}
|
||||
}
|
||||
|
||||
//NOTE : Foreign keys must be created *after* all tables of all namespaces for cross namespace fks. see HHH-10420
|
||||
for ( Namespace namespace : database.getNamespaces() ) {
|
||||
for ( Table table : namespace.getTables() ) {
|
||||
final TableInformation tableInformation = existingDatabase.getTableInformation( table.getQualifiedTableName() );
|
||||
if ( tableInformation != null && !tableInformation.isPhysicalTable() ) {
|
||||
continue;
|
||||
}
|
||||
applyForeignKeys( table, tableInformation, metadata, targets );
|
||||
}
|
||||
}
|
||||
|
||||
// Create after-table AuxiliaryDatabaseObjects
|
||||
for ( AuxiliaryDatabaseObject auxiliaryDatabaseObject : database.getAuxiliaryDatabaseObjects() ) {
|
||||
if ( !auxiliaryDatabaseObject.beforeTablesOnCreation() ) {
|
||||
|
|
Loading…
Reference in New Issue