"""platform_stat_display 增强:绝对增量增长 / 真实值偏移 / 只增不减护栏

给首页三统计配置加 5 列:
- random_kind ('mult'/'add') + random_step_min/max:自增长支持「绝对增量」(每周期 +[a,b]),不只是 ×倍率
- real_offset:真实值模式基数偏移(展示=真实+偏移,冷启动既真实又体面)
- allow_decrease:门面数字默认「只增不减」,开此开关才允许展示值下降

Revision ID: pstat3growth
Revises: marquee_seed02
Create Date: 2026-06-07 12:00:00.000000
"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


revision: str = 'pstat3growth'
down_revision: Union[str, Sequence[str], None] = 'marquee_seed02'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    with op.batch_alter_table('platform_stat_display', schema=None) as batch_op:
        batch_op.add_column(sa.Column('random_kind', sa.String(length=8), nullable=False, server_default='mult'))
        batch_op.add_column(sa.Column('random_step_min', sa.Integer(), nullable=False, server_default='0'))
        batch_op.add_column(sa.Column('random_step_max', sa.Integer(), nullable=False, server_default='0'))
        batch_op.add_column(sa.Column('real_offset', sa.Integer(), nullable=False, server_default='0'))
        batch_op.add_column(sa.Column('allow_decrease', sa.Boolean(), nullable=False, server_default=sa.false()))


def downgrade() -> None:
    with op.batch_alter_table('platform_stat_display', schema=None) as batch_op:
        batch_op.drop_column('allow_decrease')
        batch_op.drop_column('real_offset')
        batch_op.drop_column('random_step_max')
        batch_op.drop_column('random_step_min')
        batch_op.drop_column('random_kind')
