93350f4d9b
取消「同一用户同时仅一笔在途提现」限制:删应用层在途单检查 + 删 DB 分区唯一索引 ux_withdraw_order_user_active + 清理死代码 (_WITHDRAW_ACTIVE_STATUSES / WithdrawTooFrequentError)。 先扣款、coin_cash 每日档位次数、out_bill_no 幂等等既有约束不变。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
38 lines
1.4 KiB
Python
38 lines
1.4 KiB
Python
"""drop withdraw active-order partial unique index (allow multiple in-flight withdrawals)
|
|
|
|
Revision ID: drop_withdraw_active_unique_index
|
|
Revises: d8dd2106e438
|
|
Create Date: 2026-07-24 00:00:00.000000
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "drop_withdraw_active_unique_index"
|
|
down_revision: Union[str, Sequence[str], None] = "d8dd2106e438"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# 取消「同一用户同一时刻仅一笔在途提现」:允许 reviewing/pending 并存。
|
|
# 仅删本索引;姊妹索引 ux_cash_transaction_withdraw_refund_ref(退款幂等)保持不动。
|
|
op.drop_index("ux_withdraw_order_user_active", table_name="withdraw_order")
|
|
|
|
|
|
def downgrade() -> None:
|
|
# 回滚重建分区唯一索引。注意:若届时某用户已有 ≥2 张在途单,重建会因唯一冲突失败——
|
|
# 属预期的回滚代价(取消限制后本就允许多单),需先人工收敛在途单再回滚。
|
|
op.create_index(
|
|
"ux_withdraw_order_user_active",
|
|
"withdraw_order",
|
|
["user_id"],
|
|
unique=True,
|
|
sqlite_where=sa.text("status IN ('reviewing', 'pending')"),
|
|
postgresql_where=sa.text("status IN ('reviewing', 'pending')"),
|
|
)
|