"""remove legacy quality fields

Revision ID: 20251027_remove_quality
Revises: 3c4d0f57a312
Create Date: 2025-10-27

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '20251027_remove_quality'
down_revision = '3c4d0f57a312'
branch_labels = None
depends_on = None


def upgrade() -> None:
    """Remove deprecated quality fields from recipes table"""
    # Drop columns that are no longer used
    # Using batch operations for safer column drops
    with op.batch_alter_table('recipes', schema=None) as batch_op:
        batch_op.drop_column('quality_standards')
        batch_op.drop_column('quality_check_points')
        batch_op.drop_column('common_issues')


def downgrade() -> None:
    """Restore deprecated quality fields (for rollback purposes only)"""
    # Add back the columns in case of rollback
    op.add_column('recipes', sa.Column('quality_standards', sa.Text(), nullable=True))
    op.add_column('recipes', sa.Column('quality_check_points', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
    op.add_column('recipes', sa.Column('common_issues', postgresql.JSONB(astext_type=sa.Text()), nullable=True))
