-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1416 from microbiomedata/issue-1415-workflow-type…
…-migration Migrate `workflow_type` values in `data_object` table
- Loading branch information
Showing
5 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,6 @@ keys = console | |
keys = generic | ||
|
||
[logger_root] | ||
level = WARN | ||
handlers = console | ||
qualname = | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
nmdc_server/migrations/versions/e54d37bfb90b_rename_data_object_workflow_types.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
"""Rename data object workflow types | ||
The Berkeley schema migration changed a number of workflow type names. Even though | ||
the `data_object` table is truncated at the start of the ingest process, the old | ||
workflow types were being introduced by a merge operation from the live database | ||
to the ingest database. | ||
See also: https://github.com/microbiomedata/nmdc-server/issues/1415 | ||
Revision ID: e54d37bfb90b | ||
Revises: 2ec2d0b4f840 | ||
Create Date: 2024-10-11 18:06:08.521445 | ||
""" | ||
|
||
from typing import Optional | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.sql import column, table | ||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = "e54d37bfb90b" | ||
down_revision: Optional[str] = "2ec2d0b4f840" | ||
branch_labels: Optional[str] = None | ||
depends_on: Optional[str] = None | ||
|
||
|
||
WORKFLOW_TYPE_MAP = [ | ||
{ | ||
"old": "nmdc:MAGsAnalysisActivity", | ||
"new": "nmdc:MagsAnalysis", | ||
}, | ||
{ | ||
"old": "nmdc:MetabolomicsAnalysisActivity", | ||
"new": "nmdc:MetabolomicsAnalysis", | ||
}, | ||
{ | ||
"old": "nmdc:MetaProteomicAnalysis", | ||
"new": "nmdc:MetaproteomicAnalysis", | ||
}, | ||
{ | ||
"old": "nmdc:metaT", | ||
"new": "nmdc:MetatranscriptomeAnalysis", | ||
}, | ||
{ | ||
"old": "nmdc:NomAnalysisActivity", | ||
"new": "nmdc:NomAnalysis", | ||
}, | ||
{ | ||
"old": "nmdc:ReadbasedAnalysis", | ||
"new": "nmdc:ReadBasedTaxonomyAnalysis", | ||
}, | ||
{ | ||
"old": "nmdc:ReadQCAnalysisActivity", | ||
"new": "nmdc:ReadQcAnalysis", | ||
}, | ||
] | ||
|
||
|
||
def upgrade(): | ||
data_object = table("data_object", column("workflow_type", sa.String)) | ||
for mapping in WORKFLOW_TYPE_MAP: | ||
op.execute( | ||
data_object.update() | ||
.where(data_object.c.workflow_type == mapping["old"]) | ||
.values(workflow_type=mapping["new"]) | ||
) | ||
|
||
|
||
def downgrade(): | ||
data_object = table("data_object", column("workflow_type", sa.String)) | ||
for mapping in WORKFLOW_TYPE_MAP: | ||
op.execute( | ||
data_object.update() | ||
.where(data_object.c.workflow_type == mapping["new"]) | ||
.values(workflow_type=mapping["old"]) | ||
) |