From f565e8309de1eb76d85e9262274925410d05eab6 Mon Sep 17 00:00:00 2001 From: A R R R Associates Date: Sat, 19 Sep 2026 14:31:56 +0530 Subject: [PATCH] Expand AQMM reference field to text --- .../20260919_expand_aqmm_reference_to_text.py | 58 +++++++++++++++++++ app/modules/services/models.py | 6 +- 2 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 alembic/versions/20260919_expand_aqmm_reference_to_text.py diff --git a/alembic/versions/20260919_expand_aqmm_reference_to_text.py b/alembic/versions/20260919_expand_aqmm_reference_to_text.py new file mode 100644 index 0000000..e9ba5b0 --- /dev/null +++ b/alembic/versions/20260919_expand_aqmm_reference_to_text.py @@ -0,0 +1,58 @@ +"""Expand AQMM references from VARCHAR(120) to TEXT. + +Revision ID: 20260919_aqmm_ref_text +Revises: 20260919_task_inheritance +""" +from alembic import op +import sqlalchemy as sa + +revision = "20260919_aqmm_ref_text" +down_revision = "20260919_task_inheritance" +branch_labels = None +depends_on = None + +_TABLES = ( + "service_default_task_templates", + "firm_service_task_templates", + "client_service_task_instances", +) + + +def upgrade() -> None: + bind = op.get_bind() + inspector = sa.inspect(bind) + existing_tables = set(inspector.get_table_names()) + + for table_name in _TABLES: + if table_name not in existing_tables: + continue + columns = {col["name"]: col for col in inspector.get_columns(table_name)} + if "aqmm_reference" not in columns: + continue + with op.batch_alter_table(table_name) as batch: + batch.alter_column( + "aqmm_reference", + existing_type=sa.String(length=120), + type_=sa.Text(), + existing_nullable=True, + ) + + +def downgrade() -> None: + bind = op.get_bind() + inspector = sa.inspect(bind) + existing_tables = set(inspector.get_table_names()) + + for table_name in reversed(_TABLES): + if table_name not in existing_tables: + continue + columns = {col["name"]: col for col in inspector.get_columns(table_name)} + if "aqmm_reference" not in columns: + continue + with op.batch_alter_table(table_name) as batch: + batch.alter_column( + "aqmm_reference", + existing_type=sa.Text(), + type_=sa.String(length=120), + existing_nullable=True, + ) diff --git a/app/modules/services/models.py b/app/modules/services/models.py index 0a51cb7..b2c2eec 100644 --- a/app/modules/services/models.py +++ b/app/modules/services/models.py @@ -161,7 +161,7 @@ class ServiceDefaultTaskTemplate(CommonBase): aqmm_partner_review_required: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) aqmm_review_partner_required: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) aqmm_blocks_final_release: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) - aqmm_reference: Mapped[str | None] = mapped_column(String(120), nullable=True) + aqmm_reference: Mapped[str | None] = mapped_column(Text, nullable=True) is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False) @@ -238,7 +238,7 @@ class FirmServiceTaskTemplate(CommonBase): aqmm_partner_review_required: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) aqmm_review_partner_required: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) aqmm_blocks_final_release: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) - aqmm_reference: Mapped[str | None] = mapped_column(String(120), nullable=True) + aqmm_reference: Mapped[str | None] = mapped_column(Text, nullable=True) is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False) @@ -829,7 +829,7 @@ class ClientServiceTaskInstance(CommonBase): aqmm_partner_review_required: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) aqmm_review_partner_required: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) aqmm_blocks_final_release: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False) - aqmm_reference: Mapped[str | None] = mapped_column(String(120), nullable=True) + aqmm_reference: Mapped[str | None] = mapped_column(Text, nullable=True) aqmm_status: Mapped[str] = mapped_column(String(40), default="not_required", nullable=False, index=True) aqmm_review_status: Mapped[str] = mapped_column(String(40), default="not_required", nullable=False, index=True) aqmm_completed_at_utc: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)