"""coupon_claim_record 加 app_env 列(领券所属 session 环境;每券成功率表按它过滤 prod/dev)

Revision ID: coupon_claim_app_env
Revises: coupon_session_platform_success
Create Date: 2026-07-08 00:00:00.000000

"""

from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

revision: str = "coupon_claim_app_env"
down_revision: str | Sequence[str] | None = "coupon_session_platform_success"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    with op.batch_alter_table("coupon_claim_record", schema=None) as batch_op:
        batch_op.add_column(sa.Column("app_env", sa.String(length=16), nullable=True))
        batch_op.create_index(
            "ix_coupon_claim_record_app_env", ["app_env"], unique=False
        )


def downgrade() -> None:
    with op.batch_alter_table("coupon_claim_record", schema=None) as batch_op:
        batch_op.drop_index("ix_coupon_claim_record_app_env")
        batch_op.drop_column("app_env")
