HHH-10180 - Fix hbm2ddl tools cannot generate create/update script not modifying the database
This commit is contained in:
parent
e71b32fe91
commit
83a477a0d1
|
@ -177,11 +177,7 @@ public class SchemaMigratorImpl implements SchemaMigrator {
|
||||||
}
|
}
|
||||||
|
|
||||||
final TableInformation tableInformation = existingDatabase.getTableInformation( table.getQualifiedTableName() );
|
final TableInformation tableInformation = existingDatabase.getTableInformation( table.getQualifiedTableName() );
|
||||||
if ( tableInformation == null ) {
|
if ( tableInformation != null && !tableInformation.isPhysicalTable() ) {
|
||||||
// big problem...
|
|
||||||
throw new SchemaManagementException( "BIG PROBLEM" );
|
|
||||||
}
|
|
||||||
if ( !tableInformation.isPhysicalTable() ) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,10 +263,12 @@ public class SchemaMigratorImpl implements SchemaMigrator {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( tableInformation != null ) {
|
||||||
final IndexInformation existingIndex = findMatchingIndex( index, tableInformation );
|
final IndexInformation existingIndex = findMatchingIndex( index, tableInformation );
|
||||||
if ( existingIndex != null ) {
|
if ( existingIndex != null ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
applySqlStrings(
|
applySqlStrings(
|
||||||
exporter.getSqlCreateStrings( index, metadata ),
|
exporter.getSqlCreateStrings( index, metadata ),
|
||||||
|
@ -364,12 +362,16 @@ public class SchemaMigratorImpl implements SchemaMigrator {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( tableInformation != null ) {
|
||||||
final ForeignKeyInformation existingForeignKey = findMatchingForeignKey( foreignKey, tableInformation );
|
final ForeignKeyInformation existingForeignKey = findMatchingForeignKey( foreignKey, tableInformation );
|
||||||
|
if ( existingForeignKey != null ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// todo : shouldn't we just drop+recreate if FK exists?
|
// todo : shouldn't we just drop+recreate if FK exists?
|
||||||
// this follows the existing code from legacy SchemaUpdate which just skipped
|
// this follows the existing code from legacy SchemaUpdate which just skipped
|
||||||
|
|
||||||
if ( existingForeignKey == null ) {
|
|
||||||
// in old SchemaUpdate code, this was the trigger to "create"
|
// in old SchemaUpdate code, this was the trigger to "create"
|
||||||
applySqlStrings(
|
applySqlStrings(
|
||||||
exporter.getSqlCreateStrings( foreignKey, metadata ),
|
exporter.getSqlCreateStrings( foreignKey, metadata ),
|
||||||
|
@ -378,7 +380,6 @@ public class SchemaMigratorImpl implements SchemaMigrator {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private ForeignKeyInformation findMatchingForeignKey(ForeignKey foreignKey, TableInformation tableInformation) {
|
private ForeignKeyInformation findMatchingForeignKey(ForeignKey foreignKey, TableInformation tableInformation) {
|
||||||
if ( foreignKey.getName() == null ) {
|
if ( foreignKey.getName() == null ) {
|
||||||
|
|
Loading…
Reference in New Issue