Skip to content

Commit

Permalink
DbMigration: Do only real type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rPraml committed Mar 17, 2022
1 parent 923f83c commit 74720a8
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ public void generate(DdlWrite writer, AlterColumn alterColumn) {
dropCheckConstraint(writer, alterColumn, alterColumn.getCheckConstraintName());
}

if (hasValue(alterColumn.getType())
if (typeChange(alterColumn)
|| hasValue(alterColumn.getDefaultValue())
|| alterColumn.isNotnull() != null) {
alterColumn(writer, alterColumn);
Expand All @@ -735,6 +735,18 @@ public void generate(DdlWrite writer, AlterColumn alterColumn) {
}
}

private boolean typeChange(AlterColumn alterColumn) {
if (!hasValue(alterColumn.getType())) {
return false;
}
// check, if we have really a type change for that platform
// When specifying @Column("db2;clob(64K)") this would not alter
// other platforms from "String" to "String" for example
String currentType = platformDdl.convert(alterColumn.getCurrentType());
String type = platformDdl.convert(alterColumn.getType());
return !type.equals(currentType);
}

private void alterColumnComment(DdlWrite writer, AlterColumn alterColumn) {
platformDdl.addColumnComment(writer.applyPostAlter(), alterColumn.getTableName(), alterColumn.getColumnName(), alterColumn.getComment());
}
Expand Down

0 comments on commit 74720a8

Please sign in to comment.