"""add sandbox_mode to shop

Revision ID: a2c13d3117f2
Revises: f3086e09b052
Create Date: 2026-02-27 11:29:04.358964

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'a2c13d3117f2'
down_revision = 'f3086e09b052'
branch_labels = None
depends_on = None

from make_post_sell.models.meta import UUIDType


def _column_exists(table, column):
    conn = op.get_bind()
    result = conn.execute(sa.text(f"PRAGMA table_info({table})"))
    return any(row[1] == column for row in result.fetchall())


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


def downgrade():
    op.drop_column("mps_shop", "sandbox_mode")
