Skip to content

Commit

Permalink
Merge pull request #4662 from bcgov/test-marshal-RQ-4583
Browse files Browse the repository at this point in the history
Test marshal rq 4583
  • Loading branch information
richard-aot authored Oct 30, 2023
2 parents 380211f + 48001df commit 89a936d
Showing 1 changed file with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""DocumentPathMapper - update bucket name
Revision ID: 7fa7236d06fb
Revises: a79cd809e85e
Create Date: 2023-10-29 23:25:40.642169
"""
from alembic import op
import sqlalchemy as sa
import os


# revision identifiers, used by Alembic.
revision = '7fa7236d06fb'
down_revision = 'a79cd809e85e'
branch_labels = None
depends_on = None


s3environment = os.getenv('OSS_S3_ENVIRONMENT')

def upgrade():

op.execute('''
DO $BODY$
DECLARE
env text := \'''' + s3environment + '''\';
BEGIN
update public."DocumentPathMapper" set bucket = 'gcp-' || env || '-e'
where bucket = 'gcpe-' || env || '-e';
END; $BODY$
''')

op.execute('''
DO $BODY$
DECLARE
env text := \'''' + s3environment + '''\';
BEGIN
update public."DocumentPathMapper" set bucket = 'msd-' || env || '-e'
where bucket = 'sdpr-' || env || '-e';
END; $BODY$
''')

op.execute('''
DO $BODY$
DECLARE
env text := \'''' + s3environment + '''\';
BEGIN
update public."DocumentPathMapper" set bucket = 'oop-' || env || '-e'
where bucket = 'prem-' || env || '-e';
END; $BODY$
''')


def downgrade():

op.execute('''
DO $BODY$
DECLARE
env text := \'''' + s3environment + '''\';
BEGIN
update public."DocumentPathMapper" set bucket = 'gcpe-' || env || '-e'
where bucket = 'gcp-' || env || '-e';
END; $BODY$
''')

op.execute('''
DO $BODY$
DECLARE
env text := \'''' + s3environment + '''\';
BEGIN
update public."DocumentPathMapper" set bucket = 'sdpr-' || env || '-e'
where bucket = 'msd-' || env || '-e';
END; $BODY$
''')

op.execute('''
DO $BODY$
DECLARE
env text := \'''' + s3environment + '''\';
BEGIN
update public."DocumentPathMapper" set bucket = 'prem-' || env || '-e'
where bucket = 'oop-' || env || '-e';
END; $BODY$
''')

0 comments on commit 89a936d

Please sign in to comment.