From 6e5c6fa33c7aea8bae9fe8b646c93757f6b43940 Mon Sep 17 00:00:00 2001 From: Emre Dincturk <74370953+mrdnctrk@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:50:04 -0400 Subject: [PATCH] disabled old migration step that fails on fresh mssql db (#5841) --- .../tasks/HapiFhirJpaMigrationTasks.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java index e43682109b0..25094f71020 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java @@ -127,7 +127,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { Builder version = forVersion(VersionEnum.V7_2_0); - // allow null codes in concept map targets + // allow null codes in concept map targets (see comment on "20190722.27" if you are going to change this) version.onTable("TRM_CONCEPT_MAP_GRP_ELM_TGT") .modifyColumn("20240327.1", "TARGET_CODE") .nullable() @@ -2489,10 +2489,26 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { .modifyColumn("20190722.26", "SYSTEM_VERSION") .nullable() .withType(ColumnTypeEnum.STRING, 200); + + /* + DISABLED THIS STEP (20190722.27) ON PURPOSE BECAUSE IT STARTED CAUSING FAILURES ON MSSQL FOR A FRESH DB. + I left it here for historical purposes. + The reason for the failure is as follows. The TARGET_CODE column was originally 'not nullable' when it was + first introduced. And in 7_2_0, it is being changed to a nullable column (see 20240327.1 in init720()). + Starting with 7_2_0, on a fresh db, we create the table with nullable TARGET_CODE (as it is made nullable now). + Since we run all migration steps on fresh db, this step will try to convert the column which is created as nullable + to not nullable (which will then need to be coverted back to nullable in 7_2_0 migration). + Changing a nullable column to not nullable is not allowed in + MSSQL if there is an index on the column, which is the case here, as there is IDX_CNCPT_MP_GRP_ELM_TGT_CD + on this column. Since init720() has the right migration + step, where the column is set to nullable and has the right type and length, this statement is also + not necessary anymore even for not fresh dbs. + version.onTable("TRM_CONCEPT_MAP_GRP_ELM_TGT") .modifyColumn("20190722.27", "TARGET_CODE") .nonNullable() .withType(ColumnTypeEnum.STRING, 500); + */ version.onTable("TRM_CONCEPT_MAP_GRP_ELM_TGT") .modifyColumn("20190722.28", "VALUESET_URL") .nullable()