"""Widen settings.description to TEXT (was varchar(255)) Seeded setting descriptions are explanatory sentences; some exceed 255 chars (e.g. dualpath_single_machine). On strict MySQL 8 an over-length insert is a hard error 1406, not a silent truncation, so `flask seed settings` failed on a fresh box. TEXT removes the ceiling and matches value, which is already TEXT. Idempotent guard on current column type; real downgrade back to varchar(255). Revision ID: 7d26_settings_description_text Revises: 7d25_drop_redundant_indexes Create Date: 2026-07-17 """ from alembic import op import sqlalchemy as sa revision = '7d26_settings_description_text' down_revision = '7d25_drop_redundant_indexes' branch_labels = None depends_on = None def _description_type(insp): for c in insp.get_columns('settings'): if c['name'] == 'description': return str(c['type']).upper() return None def upgrade(): bind = op.get_bind() insp = sa.inspect(bind) if 'settings' not in insp.get_table_names(): return coltype = _description_type(insp) if coltype is None or 'TEXT' in coltype: return op.alter_column('settings', 'description', existing_type=sa.String(length=255), type_=sa.Text(), existing_nullable=True) def downgrade(): bind = op.get_bind() insp = sa.inspect(bind) if 'settings' not in insp.get_table_names(): return coltype = _description_type(insp) if coltype is None or 'TEXT' not in coltype: return op.alter_column('settings', 'description', existing_type=sa.Text(), type_=sa.String(length=255), existing_nullable=True)