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 62d0fd69ee7..a55f9952ad4 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 @@ -220,6 +220,14 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks { protected void init680() { Builder version = forVersion(VersionEnum.V6_8_0); + // HAPI-FHIR #4801 - Add New Index On HFJ_RESOURCE + Builder.BuilderWithTableName resourceTable = version.onTable("HFJ_RESOURCE"); + + resourceTable + .addIndex("20230502.1", "IDX_RES_RESID_UPDATED") + .unique(false) + .online(true) + .withColumns("RES_ID", "RES_UPDATED", "PARTITION_ID"); Builder.BuilderWithTableName tagDefTable = version.onTable("HFJ_TAG_DEF"); tagDefTable.dropIndex("20230505.1", "IDX_TAGDEF_TYPESYSCODEVERUS"); diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/interceptor/PatientIdPartitionInterceptorTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/interceptor/PatientIdPartitionInterceptorTest.java index d4427414795..7d428f9c67b 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/interceptor/PatientIdPartitionInterceptorTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/interceptor/PatientIdPartitionInterceptorTest.java @@ -230,11 +230,12 @@ public class PatientIdPartitionInterceptorTest extends BaseResourceProviderR4Tes Patient patient = myPatientDao.read(patientVersionOne); assertEquals("1", patient.getIdElement().getVersionIdPart()); - myCaptureQueriesListener.logSelectQueries(); - assertEquals(4, myCaptureQueriesListener.getSelectQueries().size()); - assertThat(myCaptureQueriesListener.getSelectQueries().get(0).getSql(false, false), containsString("PARTITION_ID in (?)")); - assertThat(myCaptureQueriesListener.getSelectQueries().get(1).getSql(false, false), containsString("PARTITION_ID=")); + myCaptureQueriesListener.logSelectQueriesForCurrentThread(); + List selectQueriesForCurrentThread = myCaptureQueriesListener.getSelectQueriesForCurrentThread(); + assertEquals(4, selectQueriesForCurrentThread.size()); + assertThat(selectQueriesForCurrentThread.get(0).getSql(false, false), containsString("PARTITION_ID in (?)")); + assertThat(selectQueriesForCurrentThread.get(1).getSql(false, false), containsString("PARTITION_ID=")); }