"""feedback 加提交端环境快照(app_version / device_model / rom_name / android_version)

Revision ID: feedback_submit_env
Revises: ad_pangle_daily_revenue
Create Date: 2026-06-29 00:00:00.000000

admin 用户反馈页要展示「提交版本号」「机型OS版本」,需在提交时落库端环境。仅新增可空列,
SQLite 原生支持 add_column、不用 batch;downgrade 的 drop_column 在 SQLite 走 batch 兜底。
历史反馈无此快照 → 留 NULL(无法回填);客户端改版带上后的新反馈才有值。
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = "feedback_submit_env"
down_revision: Union[str, Sequence[str], None] = "ad_pangle_daily_revenue"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.add_column("feedback", sa.Column("app_version", sa.String(length=32), nullable=True))
    op.add_column("feedback", sa.Column("device_model", sa.String(length=64), nullable=True))
    op.add_column("feedback", sa.Column("rom_name", sa.String(length=32), nullable=True))
    op.add_column("feedback", sa.Column("android_version", sa.String(length=16), nullable=True))


def downgrade() -> None:
    with op.batch_alter_table("feedback") as batch_op:
        batch_op.drop_column("android_version")
        batch_op.drop_column("rom_name")
        batch_op.drop_column("device_model")
        batch_op.drop_column("app_version")
