From 5c17eaab11afdea5abb63f1e066e6f655f0267dd Mon Sep 17 00:00:00 2001 From: Mackenzie Halliday Date: Tue, 8 Oct 2024 17:01:14 -0400 Subject: [PATCH] Squash #805 - Correct SQL to pass in proper args --- .../versions/0371_replace_template_content.py | 60 +++++++------------ 1 file changed, 22 insertions(+), 38 deletions(-) diff --git a/migrations/versions/0371_replace_template_content.py b/migrations/versions/0371_replace_template_content.py index f359a039cc..f69d6a36a7 100644 --- a/migrations/versions/0371_replace_template_content.py +++ b/migrations/versions/0371_replace_template_content.py @@ -4,49 +4,33 @@ Create Date: 2024-10-08 20:35:38 """ from alembic import op -from sqlalchemy import text revision = '371_replace_template_content' down_revision = '0370_notification_callback_url' def upgrade(): - op.execute( - text(""" - UPDATE templates - SET name = REPLACE(name, :old_name, :new_name), - content = REPLACE(content, :old_url, :new_url) - """), - { - "old_url": "https://notification.alpha.canada.ca", - "new_url": "https://api.va.gov/vanotify"} - ) + # Replace only the URLs in the 'templates' table + op.execute(""" + UPDATE templates + SET content = REPLACE(content, 'https://notification.alpha.canada.ca', 'https://api.va.gov/vanotify') + """) + + # Replace only the URLs in the 'templates_history' table + op.execute(""" + UPDATE templates_history + SET content = REPLACE(content, 'https://notification.alpha.canada.ca', 'https://api.va.gov/vanotify') + """) - op.execute( - text(""" - UPDATE templates_history - SET name = REPLACE(name, :old_name, :new_name), - content = REPLACE(content, :old_url, :new_url) - """), - { - "old_url": "https://notification.alpha.canada.ca", - "new_url": "https://api.va.gov/vanotify"} - ) def downgrade(): - op.execute( - text(""" - UPDATE templates - SET content = REPLACE(content, :new_url, :old_url) - """), - {"old_url": "https://notification.alpha.canada.ca", - "new_url": "https://api.va.gov/vanotify"} - ) - - op.execute( - text(""" - UPDATE templates_history - SET content = REPLACE(content, :new_url, :old_url) - """), - {"old_url": "https://notification.alpha.canada.ca", - "new_url": "https://api.va.gov/vanotify"} - ) + # Reverse the replacement of URLs in the 'templates' table + op.execute(""" + UPDATE templates + SET content = REPLACE(content, 'https://api.va.gov/vanotify', 'https://notification.alpha.canada.ca') + """) + + # Reverse the replacement of URLs in the 'templates_history' table + op.execute(""" + UPDATE templates_history + SET content = REPLACE(content, 'https://api.va.gov/vanotify', 'https://notification.alpha.canada.ca') + """)