"""Phase 7Q.3 user profile photo and qualification fields Revision ID: 20260531_phase_7q3_user_profile Revises: 20260530_phase_7q2_firm_branding """ from __future__ import annotations from alembic import op import sqlalchemy as sa revision = "20260531_phase_7q3_user_profile" down_revision = "20260530_phase_7q2_firm_branding" branch_labels = None depends_on = None def _columns(table_name: str) -> set[str]: bind = op.get_bind() inspector = sa.inspect(bind) return {col["name"] for col in inspector.get_columns(table_name)} def upgrade() -> None: existing = _columns("users") with op.batch_alter_table("users") as batch_op: if "profile_photo_path" not in existing: batch_op.add_column(sa.Column("profile_photo_path", sa.String(length=500), nullable=True)) if "qualification" not in existing: batch_op.add_column(sa.Column("qualification", sa.String(length=200), nullable=True)) if "designation" not in existing: batch_op.add_column(sa.Column("designation", sa.String(length=200), nullable=True)) if "mobile" not in existing: batch_op.add_column(sa.Column("mobile", sa.String(length=30), nullable=True)) if "bio" not in existing: batch_op.add_column(sa.Column("bio", sa.Text(), nullable=True)) if "signature_image_path" not in existing: batch_op.add_column(sa.Column("signature_image_path", sa.String(length=500), nullable=True)) def downgrade() -> None: existing = _columns("users") with op.batch_alter_table("users") as batch_op: for column_name in ["signature_image_path", "bio", "mobile", "designation", "qualification", "profile_photo_path"]: if column_name in existing: batch_op.drop_column(column_name)