Skip to content

Commit

Permalink
HHH-10180 - Fix hbm2ddl tools cannot generate create/update script no…
Browse files Browse the repository at this point in the history
…t modifying the database
  • Loading branch information
dreab8 committed Oct 26, 2015
1 parent 9b34880 commit fa7fcf5
Showing 1 changed file with 18 additions and 17 deletions.
Expand Up @@ -177,11 +177,7 @@ protected void doMigrationToTargets(
}

final TableInformation tableInformation = existingDatabase.getTableInformation( table.getQualifiedTableName() );
if ( tableInformation == null ) {
// big problem...
throw new SchemaManagementException( "BIG PROBLEM" );
}
if ( !tableInformation.isPhysicalTable() ) {
if ( tableInformation != null && !tableInformation.isPhysicalTable() ) {
continue;
}

Expand Down Expand Up @@ -267,9 +263,11 @@ private void applyIndexes(Table table, TableInformation tableInformation, Metada
continue;
}

final IndexInformation existingIndex = findMatchingIndex( index, tableInformation );
if ( existingIndex != null ) {
continue;
if ( tableInformation != null ) {
final IndexInformation existingIndex = findMatchingIndex( index, tableInformation );
if ( existingIndex != null ) {
continue;
}
}

applySqlStrings(
Expand Down Expand Up @@ -364,19 +362,22 @@ private void applyForeignKeys(
continue;
}

final ForeignKeyInformation existingForeignKey = findMatchingForeignKey( foreignKey, tableInformation );
if ( tableInformation != null ) {
final ForeignKeyInformation existingForeignKey = findMatchingForeignKey( foreignKey, tableInformation );
if ( existingForeignKey != null ) {
continue;
}
}

// todo : shouldn't we just drop+recreate if FK exists?
// this follows the existing code from legacy SchemaUpdate which just skipped

if ( existingForeignKey == null ) {
// in old SchemaUpdate code, this was the trigger to "create"
applySqlStrings(
exporter.getSqlCreateStrings( foreignKey, metadata ),
targets,
false
);
}
// in old SchemaUpdate code, this was the trigger to "create"
applySqlStrings(
exporter.getSqlCreateStrings( foreignKey, metadata ),
targets,
false
);
}
}

Expand Down

0 comments on commit fa7fcf5

Please sign in to comment.