Skip to content

Commit

Permalink
Merge pull request #2423 from opencb/TASK-5796
Browse files Browse the repository at this point in the history
TASK-5796 - Replace status.name indexes for status.id
  • Loading branch information
pfurio authored Apr 5, 2024
2 parents 1b6cd53 + 0d6b34a commit 2b0ab40
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.opencb.opencga.app.migrations.v2_12_4.catalog;

import org.bson.Document;
import org.opencb.opencga.catalog.db.mongodb.MongoDBAdaptorFactory;
import org.opencb.opencga.catalog.migration.Migration;
import org.opencb.opencga.catalog.migration.MigrationTool;

import java.util.Arrays;

@Migration(id = "fix_status_indexes" ,
description = "Replace 'status.name' indexes for 'status.id'",
version = "2.12.4",
domain = Migration.MigrationDomain.CATALOG,
language = Migration.MigrationLanguage.JAVA,
date = 20240328
)
public class FixStatusIndexesMigration extends MigrationTool {

@Override
protected void run() throws Exception {
Document statusIndex = new Document()
.append("status.name", 1)
.append("studyUid", 1);
dropIndex(Arrays.asList(MongoDBAdaptorFactory.JOB_COLLECTION, MongoDBAdaptorFactory.FILE_COLLECTION,
MongoDBAdaptorFactory.SAMPLE_COLLECTION, MongoDBAdaptorFactory.SAMPLE_ARCHIVE_COLLECTION,
MongoDBAdaptorFactory.COHORT_COLLECTION, MongoDBAdaptorFactory.INDIVIDUAL_COLLECTION,
MongoDBAdaptorFactory.INDIVIDUAL_ARCHIVE_COLLECTION, MongoDBAdaptorFactory.FAMILY_COLLECTION,
MongoDBAdaptorFactory.FAMILY_ARCHIVE_COLLECTION, MongoDBAdaptorFactory.PANEL_COLLECTION,
MongoDBAdaptorFactory.PANEL_ARCHIVE_COLLECTION), statusIndex);

Document internalStatusIndex = new Document()
.append("internal.status.name", 1)
.append("studyUid", 1);
dropIndex(Arrays.asList(MongoDBAdaptorFactory.JOB_COLLECTION, MongoDBAdaptorFactory.FILE_COLLECTION,
MongoDBAdaptorFactory.SAMPLE_COLLECTION, MongoDBAdaptorFactory.SAMPLE_ARCHIVE_COLLECTION,
MongoDBAdaptorFactory.COHORT_COLLECTION, MongoDBAdaptorFactory.INDIVIDUAL_COLLECTION,
MongoDBAdaptorFactory.INDIVIDUAL_ARCHIVE_COLLECTION, MongoDBAdaptorFactory.FAMILY_COLLECTION,
MongoDBAdaptorFactory.FAMILY_ARCHIVE_COLLECTION, MongoDBAdaptorFactory.PANEL_COLLECTION,
MongoDBAdaptorFactory.PANEL_ARCHIVE_COLLECTION, MongoDBAdaptorFactory.CLINICAL_ANALYSIS_COLLECTION,
MongoDBAdaptorFactory.INTERPRETATION_COLLECTION, MongoDBAdaptorFactory.INTERPRETATION_ARCHIVE_COLLECTION),
internalStatusIndex);

catalogManager.installIndexes(token);
}

}
32 changes: 16 additions & 16 deletions opencga-catalog/src/main/resources/catalog-indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
{"collections": ["job"], "fields": {"outDir.uid": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"tags": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"visited": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"internal.status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"internal.status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"internal.status.id": 1, "_priority": 1, "_creationDate": 1}, "options": {}}
{"collections": ["job"], "fields": {"_priority": 1, "_creationDate": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"_priority": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"_creationDate": 1, "studyUid": 1}, "options": {}}
Expand All @@ -53,8 +53,8 @@
{"collections": ["file"], "fields": {"_creationDate": 1, "studyUid": 1}, "options": {}}
{"collections": ["file"], "fields": {"_modificationDate": 1, "studyUid": 1}, "options": {}}
{"collections": ["file"], "fields": {"jobId": 1, "studyUid": 1}, "options": {}}
{"collections": ["file"], "fields": {"status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["file"], "fields": {"internal.status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["file"], "fields": {"status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["file"], "fields": {"internal.status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["file"], "fields": {"internal.variant.index.status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["file"], "fields": {"studyUid": 1, "_acl": 1}, "options": {}}
{"collections": ["file"], "fields": {"studyUid": 1, "release": 1, "_acl": 1}, "options": {}}
Expand Down Expand Up @@ -92,8 +92,8 @@
{"collections": ["sample", "sample_archive"], "fields": {"_ias.as": 1, "studyUid": 1}, "options": {}}
{"collections": ["sample", "sample_archive"], "fields": {"_ias.vs": 1, "studyUid": 1}, "options": {}}
{"collections": ["sample", "sample_archive"], "fields": {"_ias.id": 1, "_ias.value": 1, "studyUid": 1}, "options": {}}
{"collections": ["sample", "sample_archive"], "fields": {"internal.status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["sample", "sample_archive"], "fields": {"status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["sample", "sample_archive"], "fields": {"internal.status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["sample", "sample_archive"], "fields": {"status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["sample", "sample_archive"], "fields": {"internal.rga.status": 1, "studyUid": 1}, "options": {}}

{"collections": ["individual", "individual_archive"], "fields": {"uuid": 1, "version": 1}, "options": {"unique": true}}
Expand Down Expand Up @@ -126,8 +126,8 @@
{"collections": ["individual", "individual_archive"], "fields": {"_ias.as": 1, "studyUid": 1}, "options": {}}
{"collections": ["individual", "individual_archive"], "fields": {"_ias.vs": 1, "studyUid": 1}, "options": {}}
{"collections": ["individual", "individual_archive"], "fields": {"_ias.id": 1, "_ias.value": 1, "studyUid": 1}, "options": {}}
{"collections": ["individual", "individual_archive"], "fields": {"status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["individual", "individual_archive"], "fields": {"internal.status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["individual", "individual_archive"], "fields": {"status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["individual", "individual_archive"], "fields": {"internal.status.id": 1, "studyUid": 1}, "options": {}}

{"collections": ["cohort"], "fields": {"uuid": 1}, "options": {"unique": true}}
{"collections": ["cohort"], "fields": {"uid": 1}, "options": {"unique": true}}
Expand All @@ -146,8 +146,8 @@
{"collections": ["cohort"], "fields": {"_ias.as": 1, "studyUid": 1}, "options": {}}
{"collections": ["cohort"], "fields": {"_ias.vs": 1, "studyUid": 1}, "options": {}}
{"collections": ["cohort"], "fields": {"_ias.id": 1, "_ias.value": 1, "studyUid": 1}, "options": {}}
{"collections": ["cohort"], "fields": {"status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["cohort"], "fields": {"internal.status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["cohort"], "fields": {"status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["cohort"], "fields": {"internal.status.id": 1, "studyUid": 1}, "options": {}}

{"collections": ["family", "family_archive"], "fields": {"uuid": 1, "version": 1}, "options": {"unique": true}}
{"collections": ["family", "family_archive"], "fields": {"uid": 1, "version": 1}, "options": {"unique": true}}
Expand All @@ -170,8 +170,8 @@
{"collections": ["family", "family_archive"], "fields": {"_ias.as": 1, "studyUid": 1}, "options": {}}
{"collections": ["family", "family_archive"], "fields": {"_ias.vs": 1, "studyUid": 1}, "options": {}}
{"collections": ["family", "family_archive"], "fields": {"_ias.id": 1, "_ias.value": 1, "studyUid": 1}, "options": {}}
{"collections": ["family", "family_archive"], "fields": {"status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["family", "family_archive"], "fields": {"internal.status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["family", "family_archive"], "fields": {"status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["family", "family_archive"], "fields": {"internal.status.id": 1, "studyUid": 1}, "options": {}}

{"collections": ["panel", "panel_archive"], "fields": {"uuid": 1, "version": 1}, "options": {"unique": true}}
{"collections": ["panel", "panel_archive"], "fields": {"uid": 1, "version": 1}, "options": {"unique": true}}
Expand All @@ -189,11 +189,11 @@
{"collections": ["panel", "panel_archive"], "fields": {"categories.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["panel", "panel_archive"], "fields": {"_creationDate": 1, "studyUid": 1}, "options": {}}
{"collections": ["panel", "panel_archive"], "fields": {"_modificationDate": 1, "studyUid": 1}, "options": {}}
{"collections": ["panel", "panel_archive"], "fields": {"status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["panel", "panel_archive"], "fields": {"status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["panel", "panel_archive"], "fields": {"studyUid": 1, "_lastOfVersion": 1, "_acl": 1}, "options": {}}
{"collections": ["panel", "panel_archive"], "fields": {"studyUid": 1, "_releaseFromVersion": 1, "_lastOfRelease": 1}, "options": {}}
{"collections": ["panel", "panel_archive"], "fields": {"studyUid": 1, "release": 1, "_acl": 1}, "options": {}}
{"collections": ["panel", "panel_archive"], "fields": {"internal.status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["panel", "panel_archive"], "fields": {"internal.status.id": 1, "studyUid": 1}, "options": {}}

{"collections": ["clinical"], "fields": {"id": 1, "studyUid": 1}, "options": {"unique": true}}
{"collections": ["clinical"], "fields": {"uuid": 1}, "options": {"unique": true}}
Expand All @@ -219,7 +219,7 @@
{"collections": ["clinical"], "fields": {"_modificationDate": 1, "studyUid": 1}, "options": {}}
{"collections": ["clinical"], "fields": {"studyUid": 1, "_acl": 1}, "options": {}}
{"collections": ["clinical"], "fields": {"status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["clinical"], "fields": {"internal.status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["clinical"], "fields": {"internal.status.id": 1, "studyUid": 1}, "options": {}}

{"collections": ["interpretation", "interpretation_archive"], "fields": {"uuid": 1, "version": 1}, "options": {"unique": true}}
{"collections": ["interpretation", "interpretation_archive"], "fields": {"uid": 1, "version": 1}, "options": {"unique": true}}
Expand All @@ -234,7 +234,7 @@
{"collections": ["interpretation", "interpretation_archive"], "fields": {"_creationDate": 1, "studyUid": 1}, "options": {}}
{"collections": ["interpretation", "interpretation_archive"], "fields": {"_modificationDate": 1, "studyUid": 1}, "options": {}}
{"collections": ["interpretation", "interpretation_archive"], "fields": {"status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["interpretation", "interpretation_archive"], "fields": {"internal.status.name": 1, "studyUid": 1}, "options": {}}
{"collections": ["interpretation", "interpretation_archive"], "fields": {"internal.status.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["interpretation", "interpretation_archive"], "fields": {"studyUid": 1, "_lastOfVersion": 1}, "options": {}}
{"collections": ["interpretation", "interpretation_archive"], "fields": {"studyUid": 1, "_releaseFromVersion": 1, "_lastOfRelease": 1}, "options": {}}
{"collections": ["interpretation", "interpretation_archive"], "fields": {"studyUid": 1, "release": 1}, "options": {}}
Expand Down

0 comments on commit 2b0ab40

Please sign in to comment.