"""add grayscale_mode to shop

Revision ID: c3b37cb2c9cc
Revises: 3c0996ae20f3
Create Date: 2026-02-14 20:13:18.055029

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'c3b37cb2c9cc'
down_revision = '3c0996ae20f3'
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", "grayscale_mode"):
        op.add_column(
            "mps_shop",
            sa.Column("grayscale_mode", sa.Boolean(), nullable=False, server_default="0"),
        )


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