From 66028d2eae141bc047e6ce4c0ab59dbfdc6f07eb Mon Sep 17 00:00:00 2001 From: Karel van Klink <karel.vanklink@geant.org> Date: Fri, 18 Apr 2025 09:50:09 +0200 Subject: [PATCH] Add a migration to clean up IP Trunk subscription descriptions --- ...fe36624681_update_ip_trunk_descriptions.py | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 gso/migrations/versions/2025-04-18_fffe36624681_update_ip_trunk_descriptions.py diff --git a/gso/migrations/versions/2025-04-18_fffe36624681_update_ip_trunk_descriptions.py b/gso/migrations/versions/2025-04-18_fffe36624681_update_ip_trunk_descriptions.py new file mode 100644 index 000000000..4402b1ef3 --- /dev/null +++ b/gso/migrations/versions/2025-04-18_fffe36624681_update_ip_trunk_descriptions.py @@ -0,0 +1,38 @@ +"""Update IP Trunk descriptions. + +Removes an outdated to `geant_s_sid` in IP Trunk descriptions. This field has been renamed and adds unnecessary clutter +to the description field. + +Revision ID: fffe36624681 +Revises: c38adde1a18e +Create Date: 2025-04-18 09:41:28.463681 + +""" +import sqlalchemy as sa +from alembic import op + +# revision identifiers, used by Alembic. +revision = 'fffe36624681' +down_revision = 'c38adde1a18e' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + conn = op.get_bind() + conn.execute( + sa.text( + """ +UPDATE subscriptions +SET description = Replace(description, 'geant_s_sid:', '') +WHERE product_id = (SELECT product_id + FROM products p + WHERE p.tag = 'IPTRUNK'); + """ + ) + ) + + +def downgrade() -> None: + # Do nothing + pass -- GitLab