From 764352afc7b2b29d0bb026c7bb2ecfc1434c4a3c Mon Sep 17 00:00:00 2001 From: Goffi Date: Tue, 6 May 2025 00:19:43 +0200 Subject: [PATCH] storage: Add missing migration script to use JSON type instead of TEXT in History and private binary data. --- ...6b6d4_use_json_type_in_history_and_for_.py | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 libervia/backend/memory/migration/versions/29f85e56b6d4_use_json_type_in_history_and_for_.py diff --git a/libervia/backend/memory/migration/versions/29f85e56b6d4_use_json_type_in_history_and_for_.py b/libervia/backend/memory/migration/versions/29f85e56b6d4_use_json_type_in_history_and_for_.py new file mode 100644 index 00000000..e347b926 --- /dev/null +++ b/libervia/backend/memory/migration/versions/29f85e56b6d4_use_json_type_in_history_and_for_.py @@ -0,0 +1,56 @@ +"""use JSON type in History and for private bin values + +Revision ID: 29f85e56b6d4 +Revises: fe3a02cb4bec +Create Date: 2025-05-02 11:20:11.555189 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '29f85e56b6d4' +down_revision = 'fe3a02cb4bec' +branch_labels = None +depends_on = None + + +def upgrade(): + with op.batch_alter_table('history', schema=None) as batch_op: + batch_op.alter_column('extra', + existing_type=sa.TEXT(), + type_=sa.JSON(), + existing_nullable=True) + + with op.batch_alter_table('private_gen_bin', schema=None) as batch_op: + batch_op.alter_column('value', + existing_type=sa.TEXT(), + type_=sa.JSON(), + existing_nullable=True) + + with op.batch_alter_table('private_ind_bin', schema=None) as batch_op: + batch_op.alter_column('value', + existing_type=sa.TEXT(), + type_=sa.JSON(), + existing_nullable=True) + + +def downgrade(): + with op.batch_alter_table('private_ind_bin', schema=None) as batch_op: + batch_op.alter_column('value', + existing_type=sa.JSON(), + type_=sa.TEXT(), + existing_nullable=True) + + with op.batch_alter_table('private_gen_bin', schema=None) as batch_op: + batch_op.alter_column('value', + existing_type=sa.JSON(), + type_=sa.TEXT(), + existing_nullable=True) + + with op.batch_alter_table('history', schema=None) as batch_op: + batch_op.alter_column('extra', + existing_type=sa.JSON(), + type_=sa.TEXT(), + existing_nullable=True)