From 06ffee18a0594e19855981ebec2be9f64fbba2d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20BECOT?= Date: Thu, 5 May 2022 00:41:19 +0200 Subject: [PATCH] fix: Provide an Alembic update script to fixe quotes --- ...c7cf864b24_update_history_detail_quotes.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 migrations/versions/fbc7cf864b24_update_history_detail_quotes.py diff --git a/migrations/versions/fbc7cf864b24_update_history_detail_quotes.py b/migrations/versions/fbc7cf864b24_update_history_detail_quotes.py new file mode 100644 index 0000000..4aaf16c --- /dev/null +++ b/migrations/versions/fbc7cf864b24_update_history_detail_quotes.py @@ -0,0 +1,47 @@ +"""update history detail quotes + +Revision ID: fbc7cf864b24 +Revises: 0967658d9c0d +Create Date: 2022-05-04 19:49:54.054285 + +""" +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = 'fbc7cf864b24' +down_revision = '0967658d9c0d' +branch_labels = None +depends_on = None + + +def upgrade(): + history_table = sa.sql.table( + 'history', + sa.Column('id', sa.Integer), + sa.Column('msg', sa.String), + sa.Column('detail', sa.Text), + sa.Column('created_by', sa.String), + sa.Column('created_on', sa.DateTime), + sa.Column('domain_id', sa.Integer) + ) + + op.execute( + history_table.update().where( + sa.and_( + history_table.c.detail.like("%'%"), + history_table.c.detail.notlike("%rrests%"), + history_table.c.detail.notlike("%rrsets%") + ) + ).values({ + 'detail': sa.func.replace( + history_table.c.detail, + "'", + '"' + ) + }) + ) + + +def downgrade(): + pass