"""coupon_session 加 origin_package 列(发起来源 App 包名 → admin「发起平台」)

null=App 内(傻瓜比价首页)发起,非空=从美团/淘宝/京东弹券发起。与 trace_url 同理单独成迁移,
已建表环境靠它补列、全新环境顺序应用,不重复加列。

Revision ID: coupon_session_origin_package
Revises: coupon_session_trace_url
Create Date: 2026-06-30 00:00:00.000000

"""

from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision: str = "coupon_session_origin_package"
down_revision: str | Sequence[str] | None = "coupon_session_trace_url"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    with op.batch_alter_table("coupon_session", schema=None) as batch_op:
        batch_op.add_column(sa.Column("origin_package", sa.String(length=64), nullable=True))


def downgrade() -> None:
    with op.batch_alter_table("coupon_session", schema=None) as batch_op:
        batch_op.drop_column("origin_package")
