HHH-12271 - SchemaDropperImpl does not drop constraints with IF EXISTS

This commit is contained in:
Andrea Boriero 2018-02-05 13:35:41 +00:00
parent e92f350e22
commit 6bf2869355
1 changed files with 23 additions and 10 deletions

View File

@ -145,8 +145,21 @@ public class StandardForeignKeyExporter implements Exporter<ForeignKey> {
dialect
);
return new String[] {
dialect.getAlterTableString( sourceTableName )
+ dialect.getDropForeignKeyString() + foreignKey.getName()
getSqlDropStrings( sourceTableName, foreignKey, dialect )
};
}
private String getSqlDropStrings(String tableName, ForeignKey foreignKey, Dialect dialect) {
final StringBuilder buf = new StringBuilder( dialect.getAlterTableString( tableName ) );
buf.append( dialect.getDropForeignKeyString() );
if ( dialect.supportsIfExistsBeforeConstraintName() ) {
buf.append( "if exists " );
}
buf.append( dialect.quote( foreignKey.getName() ) );
if ( dialect.supportsIfExistsAfterConstraintName() ) {
buf.append( " if exists" );
}
return buf.toString();
}
}