Fix MS SQLServer database migration

This commit is contained in:
Jason Roberts 2021-09-21 10:42:59 -04:00
parent f1f9c672ad
commit b6c8658f8c
4 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,4 @@
---
type: fix
issue: 3012
title: "Fixes some recent database schema migration failures on MS SQLServer."

View File

@ -221,6 +221,14 @@ public class TestUtil {
}
for (Class<?> innerClass : theClazz.getDeclaredClasses()) {
Embeddable embeddable = innerClass.getAnnotation(Embeddable.class);
if (embeddable != null) {
scanClassOrSuperclass(theNames, innerClass, false, columnNameToLength);
}
}
if (theClazz.getSuperclass().equals(Object.class)) {
return;
}

View File

@ -254,6 +254,13 @@ public class JdbcUtils {
return new ColumnType(ColumnTypeEnum.DATE_TIMESTAMP, length);
case Types.BLOB:
return new ColumnType(ColumnTypeEnum.BLOB, length);
case Types.VARBINARY:
if (theConnectionProperties.getDriverType().equals(DriverTypeEnum.MSSQL_2012)) {
// MS SQLServer seems to be mapping BLOB to VARBINARY under the covers, so we need to reverse that mapping
return new ColumnType(ColumnTypeEnum.BLOB, length);
} else {
throw new IllegalArgumentException("Don't know how to handle datatype " + dataType + " for column " + theColumnName + " on table " + theTableName);
}
case Types.CLOB:
return new ColumnType(ColumnTypeEnum.CLOB, length);
case Types.DOUBLE:

View File

@ -148,6 +148,11 @@ public class Builder {
super.addTask(theTask);
}
}
public BuilderAddTableByColumns failureAllowed() {
myTask.setFailureAllowed(true);
return this;
}
}
public static class BuilderWithTableName implements BaseMigrationTasks.IAcceptsTasks {