Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-5796 - Replace status.name indexes for status.id #2423

Merged
merged 3 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading