"""Widen musehub_symbol_intel.op from VARCHAR(16) to VARCHAR(32). Revision ID: 0041 Revises: 0040 Create Date: 2026-05-07 Staging had VARCHAR(16) on this column; ORM model defines String(32). Uses IF column length check so migration is safe to run on DBs where the column is already the correct size. """ from __future__ import annotations from alembic import op import sqlalchemy as sa revision: str = "0041" down_revision: str | None = "0040" branch_labels = None depends_on = None def upgrade() -> None: bind = op.get_bind() cols = {c["name"]: c for c in sa.inspect(bind).get_columns("musehub_symbol_intel")} op_col = cols.get("op") if op_col and isinstance(op_col["type"], sa.VARCHAR) and op_col["type"].length == 16: op.alter_column( "musehub_symbol_intel", "op", existing_type=sa.VARCHAR(length=16), type_=sa.String(length=32), existing_nullable=True, ) def downgrade() -> None: bind = op.get_bind() cols = {c["name"]: c for c in sa.inspect(bind).get_columns("musehub_symbol_intel")} op_col = cols.get("op") if op_col and isinstance(op_col["type"], sa.VARCHAR) and op_col["type"].length == 32: op.alter_column( "musehub_symbol_intel", "op", existing_type=sa.String(length=32), type_=sa.VARCHAR(length=16), existing_nullable=True, )