From 709aeb4ae8f7635a9c2ff4ea3606d66549b73d28 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Mon, 3 Feb 2020 10:29:39 -0500 Subject: [PATCH] Drop unnecessary index (#1696) --- .../ITermValueSetConceptDesignationDao.java | 4 ---- .../TermValueSetConceptDesignation.java | 4 +--- .../tasks/HapiFhirJpaMigrationTasks.java | 9 +++++++- .../fhir/jpa/migrate/tasks/api/Builder.java | 22 ++++++++++++++----- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermValueSetConceptDesignationDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermValueSetConceptDesignationDao.java index cc84b88412a..49a1f0367da 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermValueSetConceptDesignationDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/data/ITermValueSetConceptDesignationDao.java @@ -21,8 +21,6 @@ package ca.uhn.fhir.jpa.dao.data; */ import ca.uhn.fhir.jpa.entity.TermValueSetConceptDesignation; -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Slice; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; @@ -37,6 +35,4 @@ public interface ITermValueSetConceptDesignationDao extends JpaRepository findByTermValueSetConceptId(Pageable thePage, @Param("pid") Long theValueSetConceptId); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetConceptDesignation.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetConceptDesignation.java index ea6582e49cf..bca66a3792b 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetConceptDesignation.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/entity/TermValueSetConceptDesignation.java @@ -33,9 +33,7 @@ import java.io.Serializable; import static org.apache.commons.lang3.StringUtils.left; import static org.apache.commons.lang3.StringUtils.length; -@Table(name = "TRM_VALUESET_C_DESIGNATION", indexes = { - @Index(name = "IDX_VALUESET_C_DSGNTN_VAL", columnList = "VAL") -}) +@Table(name = "TRM_VALUESET_C_DESIGNATION") @Entity() public class TermValueSetConceptDesignation implements Serializable { private static final long serialVersionUID = 1L; 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 53489f0c607..f304bf98e8e 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 @@ -186,6 +186,10 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { // TermConceptProperty version.startSectionWithMessage("Processing table: TRM_CONCEPT_PROPERTY"); version.onTable("TRM_CONCEPT_PROPERTY").addColumn("20191002.9", "PROP_VAL_LOB").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.BLOB); + + // TermValueSetConceptDesignation + version.onTable("TRM_VALUESET_C_DESIGNATION").dropIndex("20200202.1", "IDX_VALUESET_C_DSGNTN_VAL").failureAllowed(); + } protected void init400() { // 20190401 - 20190814 @@ -324,10 +328,13 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { termValueSetConceptDesignationTable.addColumn("USE_CODE").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 500); termValueSetConceptDesignationTable.addColumn("USE_DISPLAY").nullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 500); termValueSetConceptDesignationTable.addColumn("VAL").nonNullable().type(BaseTableColumnTypeTask.ColumnTypeEnum.STRING, 500); + + // This index turned out not to be needed so it is disabled termValueSetConceptDesignationTable .addIndex("20190801.6", "IDX_VALUESET_C_DSGNTN_VAL") .unique(false) - .withColumns("VAL"); + .withColumns("VAL") + .doNothing(); // TermCodeSystemVersion version.startSectionWithMessage("Processing table: TRM_CODESYSTEM_VER"); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/Builder.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/Builder.java index a7de3803e1d..ea6431e8fbb 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/Builder.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/Builder.java @@ -158,20 +158,22 @@ public class Builder { return myTableName; } - public void dropIndex(String theVersion, String theIndexName) { - dropIndexOptional(false, theVersion, theIndexName); + public BuilderCompleteTask dropIndex(String theVersion, String theIndexName) { + BaseTask task = dropIndexOptional(false, theVersion, theIndexName); + return new BuilderCompleteTask(task); } public void dropIndexStub(String theVersion, String theIndexName) { dropIndexOptional(true, theVersion, theIndexName); } - private void dropIndexOptional(boolean theDoNothing, String theVersion, String theIndexName) { + private DropIndexTask dropIndexOptional(boolean theDoNothing, String theVersion, String theIndexName) { DropIndexTask task = new DropIndexTask(myRelease, theVersion); task.setIndexName(theIndexName); task.setTableName(myTableName); task.setDoNothing(theDoNothing); addTask(task); + return task; } public void renameIndex(String theVersion, String theOldIndexName, String theNewIndexName) { @@ -286,11 +288,12 @@ public class Builder { withColumnsOptional(true, theColumnNames); } - public void withColumns(String... theColumnNames) { - withColumnsOptional(false, theColumnNames); + public BuilderCompleteTask withColumns(String... theColumnNames) { + BaseTask task = withColumnsOptional(false, theColumnNames); + return new BuilderCompleteTask(task); } - private void withColumnsOptional(boolean theDoNothing, String... theColumnNames) { + private AddIndexTask withColumnsOptional(boolean theDoNothing, String... theColumnNames) { AddIndexTask task = new AddIndexTask(myRelease, myVersion); task.setTableName(myTableName); task.setIndexName(myIndexName); @@ -298,6 +301,7 @@ public class Builder { task.setColumns(theColumnNames); task.setDoNothing(theDoNothing); addTask(task); + return task; } } } @@ -463,6 +467,12 @@ public class Builder { myTask.setFailureAllowed(true); return this; } + + public BuilderCompleteTask doNothing() { + myTask.setDoNothing(true); + return this; + } + } }