"""admin_user 加 plain_password 列(明文登录密码,仅后台 UI 建/重置的账号留存)

权限管理页需能复看某成员已确定的登录密码转交本人。系统只存哈希无法反推,故对「后台 UI 创建/重置」
的管理员额外留存一份明文;脚本/起后台建的超管为 None(前端不显示密码)。旧账号无此列值 → 同样不显示。

Revision ID: admin_user_plain_password
Revises: admin_role_table
Create Date: 2026-07-04 00:00:00.000000
"""
from collections.abc import Sequence

import sqlalchemy as sa

from alembic import op

revision: str = "admin_user_plain_password"
down_revision: str | Sequence[str] | None = "admin_role_table"
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


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


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