diff --git a/shared/workspaces/alembic/versions/49b7c8150e72_workflows_oracle_update.py b/shared/workspaces/alembic/versions/49b7c8150e72_workflows_oracle_update.py new file mode 100644 index 0000000000000000000000000000000000000000..2f6ffb8c6496f9369a2c0efbd33d74097a57a46b --- /dev/null +++ b/shared/workspaces/alembic/versions/49b7c8150e72_workflows_oracle_update.py @@ -0,0 +1,100 @@ +"""workflows oracle update + +Revision ID: 49b7c8150e72 +Revises: f2a76d224984 +Create Date: 2023-11-22 14:26:55.355861 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '49b7c8150e72' +down_revision = 'f2a76d224984' +branch_labels = None +depends_on = None + + +# Add instantclient_21_1 to the path for CV nodes +old_curator_condor = """executable = curator.sh +arguments = metadata.json {{curator_type}} + +output = curator.out +error = curator.err +log = condor.log + +should_transfer_files = NO ++WantIOProxy = True +request_memory = {{ramInGb}} +getenv = True +environment = "CAPO_PATH=/home/casa/capo" +requirements = HasLustre == True + +queue + +""" + +new_curator_condor = """executable = curator.sh +arguments = metadata.json {{curator_type}} + +output = curator.out +error = curator.err +log = condor.log + +should_transfer_files = NO ++WantIOProxy = True +request_memory = {{ramInGb}} +{{^remote-cv}} +getenv = True +environment = "CAPO_PATH=/home/casa/capo" + +requirements = HasLustre == True +{{/remote-cv}} +{{#remote-cv}} +environment = "CAPO_PATH=. CAPO_PROFILE={{profile}} LD_LIBRARY_PATH=/home/ssa/share/oracle/instantclient_21_1" + +requirements = HasLustre == True && (CVPOST == True) ++partition = "CVPOST" +{{/remote-cv}} + +queue + +""" + + +def upgrade(): + op.execute( + f""" + UPDATE workflow_templates + SET content=E'{new_curator_condor}' + WHERE filename='curator.condor' + """ + ) + + # Use instantclient_21_1 in the other templates + op.execute( + f""" + UPDATE workflow_templates + SET content= regexp_replace(convert_from(content, 'utf-8'), E'instantclient_12_1', E'instantclient_21_1', 'g')::bytea + WHERE filename='download.condor' OR filename='ingest_cal.condor' + """ + ) + + +def downgrade(): + op.execute( + f""" + UPDATE workflow_templates + SET content=E'{old_curator_condor}' + WHERE filename='curator.condor' + """ + ) + + op.execute( + f""" + UPDATE workflow_templates + SET content= regexp_replace(convert_from(content, 'utf-8'), E'instantclient_21_1', E'instantclient_12_1', 'g')::bytea + WHERE filename='download.condor' OR filename='ingest_cal.condor' + """ + )