changeset 4364:fa300abc3cb6

storage: Add missing migration script to use JSON type instead of TEXT in History and private binary data.
author Goffi <goffi@goffi.org>
date Tue, 06 May 2025 00:19:43 +0200
parents 4da560a8aed3
children f6672bc80897
files libervia/backend/memory/migration/versions/29f85e56b6d4_use_json_type_in_history_and_for_.py
diffstat 1 files changed, 56 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libervia/backend/memory/migration/versions/29f85e56b6d4_use_json_type_in_history_and_for_.py	Tue May 06 00:19:43 2025 +0200
@@ -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)