diff --git a/shared/workspaces/alembic/versions/569416c40ca8_ingest_obs_workflow_renaming.py b/shared/workspaces/alembic/versions/569416c40ca8_ingest_obs_workflow_renaming.py new file mode 100644 index 0000000000000000000000000000000000000000..d2e3775fa664abe5ce3446014ea766a520b143a3 --- /dev/null +++ b/shared/workspaces/alembic/versions/569416c40ca8_ingest_obs_workflow_renaming.py @@ -0,0 +1,60 @@ +"""ingest obs workflow renaming + +Revision ID: 569416c40ca8 +Revises: 08090cb7acc4 +Create Date: 2023-09-20 09:34:23.628834 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '569416c40ca8' +down_revision = '08090cb7acc4' +branch_labels = None +depends_on = None + +old_ingest_obs_sh = """#!/bin/sh +set -o errexit + +./ingest_envoy --observation $1 $2 + +""" + +# Workflow will rename the directory to indicate the ingestion status +new_ingest_obs_sh = """#!/bin/sh +set -o errexit + +running=$2.running +ingested=$2.ingested +failed=$2.failed + +mv $2 $running + +./ingest_envoy --observation $1 $running + +status=$? +[ $status -eq 0 ] && mv $running $ingested || mv $running $failed + +""" + + +def upgrade(): + op.execute( + f""" + UPDATE workflow_templates + SET content=E'{new_ingest_obs_sh}' + WHERE filename='ingest_obs.sh' + """ + ) + + +def downgrade(): + op.execute( + f""" + UPDATE workflow_templates + SET content=E'{old_ingest_obs_sh}' + WHERE filename='ingest_obs.sh' + """ + )