Skip to content

Commit db2f0f1

Browse files
committed
HHH-18784 TableMigrator shouldn't alter column length if actual is greater than default
1 parent 76f2243 commit db2f0f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hibernate-core/src/main/java/org/hibernate/tool/schema/internal/ColumnDefinitions.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ static boolean hasMatchingLength(Column column, ColumnInformation columnInformat
6363
final Size size = column.getColumnSize( dialect, metadata );
6464
final Long requiredLength = size.getLength();
6565
return requiredLength == null
66-
|| requiredLength == actualLength;
66+
|| requiredLength == actualLength
67+
|| !column.isExplicit() && requiredLength < actualLength;
6768
}
6869
else if ( isNumericOrDecimal( sqlType ) ) {
6970
// Postgres, H2, SQL Server, and MySQL agree on the following:
@@ -74,7 +75,8 @@ else if ( isNumericOrDecimal( sqlType ) ) {
7475
final Integer requiredScale = size.getScale();
7576
return requiredPrecision == null
7677
|| requiredScale == null
77-
|| requiredScale == actualScale && requiredPrecision == actualPrecision;
78+
|| requiredScale == actualScale && requiredPrecision == actualPrecision
79+
|| !column.isExplicit() && requiredScale <= actualScale && requiredPrecision <= actualPrecision;
7880
}
7981
// I would really love this to be able to change the binary
8082
// precision of a float/double type, but there simply doesn't

0 commit comments

Comments
 (0)