"""add public_sales_stats to shop

Revision ID: 1a2b3c4d5e6f
Revises: 0ee5654cfe7d
Create Date: 2026-04-10 00:00:00.000000

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '1a2b3c4d5e6f'
down_revision = '0ee5654cfe7d'
branch_labels = None
depends_on = None


def _column_exists(table, column):
    from alembic import op as _op
    from sqlalchemy import inspect
    bind = _op.get_bind()
    insp = inspect(bind)
    return column in [c["name"] for c in insp.get_columns(table)]


def upgrade():
    if not _column_exists('mps_shop', 'public_sales_stats'):
        op.add_column(
            'mps_shop',
            sa.Column('public_sales_stats', sa.Boolean(), nullable=False, server_default='0'),
        )


def downgrade():
    if _column_exists('mps_shop', 'public_sales_stats'):
        op.drop_column('mps_shop', 'public_sales_stats')
