diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java index 7d5d634f5d5..615054cbcf4 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java @@ -41,10 +41,7 @@ import org.springframework.jdbc.core.ColumnMapRowMapper; import javax.sql.DataSource; import java.sql.*; -import java.util.HashSet; -import java.util.Locale; -import java.util.Objects; -import java.util.Set; +import java.util.*; import static org.thymeleaf.util.StringUtils.toUpperCase; @@ -56,6 +53,10 @@ public class JdbcUtils { */ public static Set getIndexNames(DriverTypeEnum.ConnectionProperties theConnectionProperties, String theTableName) throws SQLException { + if (!getTableNames(theConnectionProperties).contains(theTableName)) { + return Collections.emptySet(); + } + DataSource dataSource = Objects.requireNonNull(theConnectionProperties.getDataSource()); try (Connection connection = dataSource.getConnection()) { return theConnectionProperties.getTxTemplate().execute(t -> { diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java index 14525617259..8fbdc47ed8c 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java @@ -86,10 +86,6 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { version.onTable("TRM_VALUESET") .renameColumn("NAME", "VSNAME", true, true); - version.onTable("TRM_VALUESET_CONCEPT") - .renameColumn("CODE", "CODEVAL", true, true) - .renameColumn("SYSTEM", "SYSTEM_URL", true, true); - version.onTable("TRM_CONCEPT") .renameColumn("CODE", "CODEVAL", false, true); @@ -127,6 +123,9 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { .unique(false) .withColumns("SYSTEM_URL", "CODEVAL"); termValueSetConceptTable.addColumn("DISPLAY").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, TermConcept.MAX_DESC_LENGTH); + version.onTable("TRM_VALUESET_CONCEPT") + .renameColumn("CODE", "CODEVAL", true, true) + .renameColumn("SYSTEM", "SYSTEM_URL", true, true); // TermValueSetConceptDesignation version.startSectionWithMessage("Processing table: TRM_VALUESET_C_DESIGNATION");