Skip to content

Commit

Permalink
app: create migration scripts, #TASK-6445
Browse files Browse the repository at this point in the history
  • Loading branch information
pfurio committed Nov 13, 2024
1 parent 6a17eec commit d0d8346
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.opencb.opencga.app.migrations.v4.v4_0_0.catalog;

import org.opencb.opencga.catalog.migration.Migration;
import org.opencb.opencga.catalog.migration.MigrationTool;

@Migration(id = "new_indexes_6445",
description = "New indexes from #TASK-6445", version = "4.0.0",
language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20241113)
public class IndexesTask6445 extends MigrationTool {

@Override
protected void run() throws Exception {
catalogManager.installIndexes(organizationId, token);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.opencb.opencga.app.migrations.v4.v4_0_0.catalog;


import com.mongodb.client.model.Filters;
import com.mongodb.client.model.Updates;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.opencb.opencga.catalog.db.mongodb.OrganizationMongoDBAdaptorFactory;
import org.opencb.opencga.catalog.migration.Migration;
import org.opencb.opencga.catalog.migration.MigrationTool;

import java.util.Arrays;
import java.util.Collections;

@Migration(id = "job_model_changes_6445",
description = "Job data model changes #TASK-6445", version = "4.0.0",
language = Migration.MigrationLanguage.JAVA, domain = Migration.MigrationDomain.CATALOG, date = 20241113)
public class JobModelChangesMigrationTask6445 extends MigrationTool {

@Override
protected void run() throws Exception {
Bson query = Filters.exists("type", false);
Bson update = Updates.combine(
Updates.set("type", "NATIVE"),
Updates.set("tool.minimumRequirements", new Document()),
Updates.set("execution.dependencies", Collections.emptyList())
);
for (String collection : Arrays.asList(OrganizationMongoDBAdaptorFactory.JOB_COLLECTION,
OrganizationMongoDBAdaptorFactory.DELETED_JOB_COLLECTION)) {
getMongoCollection(collection).updateMany(query, update);
}
}

}
1 change: 0 additions & 1 deletion opencga-catalog/src/main/resources/catalog-indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
{"collections": ["job"], "fields": {"id": 1, "studyUid": 1}, "options": {"unique": true}}
{"collections": ["job"], "fields": {"tool.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"tool.type": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"tool.externalExecutor.id": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"userId": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"parentId": 1, "studyUid": 1}, "options": {}}
{"collections": ["job"], "fields": {"outDir.uid": 1, "studyUid": 1}, "options": {}}
Expand Down

0 comments on commit d0d8346

Please sign in to comment.