-
Notifications
You must be signed in to change notification settings - Fork 3
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 #4662 from bcgov/test-marshal-RQ-4583
Test marshal rq 4583
- Loading branch information
Showing
1 changed file
with
85 additions
and
0 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
...-management-api/migrations/versions/7fa7236d06fb_documentpathmapper_update_bucket_name.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,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$ | ||
''') |