"""add discovery ring to shop

Revision ID: 05f7eb8cecf1
Revises: c3f9d1cdffb4
Create Date: 2026-02-08 15:27:04.955833

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '05f7eb8cecf1'
down_revision = 'c3f9d1cdffb4'
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", "json_discovery_ring"):
        op.add_column(
            "mps_shop",
            sa.Column("json_discovery_ring", sa.UnicodeText(), nullable=True),
        )


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