"""add ad_type to ad_feed_reward and feed_scene to ad_ecpm

把信息流广告全面改造成 Draw 信息流(draw):
- ad_feed_reward_record.ad_type:广告形态 feed(信息流) / draw(Draw 信息流)。可空,旧数据 NULL
  一律视为 feed(向后兼容);每日上限与因子2(LT)仍按本表全表 unit 累计,不按 ad_type 拆。
- ad_ecpm_record.feed_scene:点位场景 comparison(比价) / coupon(领券) / welfare(福利),供广告
  收益报表区分比价/领券 Draw 收益;仅信息流/Draw 上报,激励视频为 NULL。

注:autogenerate 会顺带探测到 analytics_event / cps_* / invite_fingerprint 等无关索引差异(本地库与
metadata 漂移、analytics 模型尚未并入 __init__),与本次改动无关,已手工剔除——本迁移只 add 两列。
SQLite 经 env.py 的 render_as_batch 自动走 batch_alter_table 重建表。

Revision ID: c2874d2bf705
Revises: 1699fc2c069f
Create Date: 2026-06-26 16:48:52.158609

"""
from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

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


def upgrade() -> None:
    # 信息流发奖记录:新增广告形态 feed/draw(可空,旧数据 NULL=feed)
    op.add_column(
        "ad_feed_reward_record",
        sa.Column("ad_type", sa.String(length=16), nullable=True),
    )
    # eCPM 展示上报:新增点位场景 comparison/coupon/welfare(可空,激励视频/旧数据 NULL)
    op.add_column(
        "ad_ecpm_record",
        sa.Column("feed_scene", sa.String(length=16), nullable=True),
    )


def downgrade() -> None:
    op.drop_column("ad_ecpm_record", "feed_scene")
    op.drop_column("ad_feed_reward_record", "ad_type")
