"""ad revenue report columns: app_env + our_code_id

给 ad_ecpm_record / ad_reward_record / ad_feed_reward_record 各加两列:
- app_env:我们的穿山甲应用环境(prod=傻瓜比价正式 / test=测试应用)
- our_code_id:我们在穿山甲后台配置的代码位 ID(104xxx,非底层 mediation rit)

供「广告收益报表」按 用户/日期/广告类型/应用/代码位 聚合 展示条数/收益/金币。
旧数据这两列为 NULL(报表里来源列留空),新数据由客户端上报/发奖时回填。

Revision ID: ad_revenue_report_cols
Revises: coupon_engage_per_package
Create Date: 2026-06-15
"""

from __future__ import annotations

from alembic import op
import sqlalchemy as sa


revision = "ad_revenue_report_cols"
down_revision = "coupon_engage_per_package"
branch_labels = None
depends_on = None


_TABLES = ("ad_ecpm_record", "ad_reward_record", "ad_feed_reward_record")


def upgrade() -> None:
    for table in _TABLES:
        op.add_column(table, sa.Column("app_env", sa.String(length=16), nullable=True))
        op.add_column(table, sa.Column("our_code_id", sa.String(length=64), nullable=True))


def downgrade() -> None:
    for table in _TABLES:
        op.drop_column(table, "our_code_id")
        op.drop_column(table, "app_env")
