fix(shipping-notice): 库存 RPA 回调 source_run_no 列加宽到 128

- shipping_task_inventory_rpa_attempts.source_run_no 64→128,与模型 String(128)
  对齐;RPA Worker 回传编号由源系统/仓库/厂商等外部段拼装、长度不受后端控制,
  65 字符组合超 64 上限致库存准备门禁 Attempt 终态失败(2026-09-27 test 8878)
- 补齐历史欠账:gw4d5e6f7g8h 仅做 run_no→source_run_no 改名漏了加宽
- downgrade 收窄前须确认无 >64 长度行,不做静默截断(截断破坏回关联)
This commit is contained in:
hugo committed 2026-09-27 22:43:48 +08:00
1 parent 393a8f6858
commit 9c7776b5cb
1 file changed
+49
@@ -0,0 +1,49 @@
"""Widen inventory RPA attempts.source_run_no to 128.
Revision ID: we9f0a1b2c3d
Revises: wd7e8f9a0b1c
Create Date: 2026-09-27 00:00:00.000000
用途:shipping_task_inventory_rpa_attempts.source_run_no 由 varchar(64) 加宽到
varchar(128),与模型 String(128) 对齐。
依赖:shipping_task_inventory_rpa_attempts 表(含 uq_shipping_task_inv_rpa_triplet
唯一约束,覆盖 task_no/source_code/source_run_no 三列)。
逻辑:RPA Worker 回传的 source_run_no 由源系统/仓库/厂商/尝试序号等外部段拼装,
长度不受后端控制(2026-09-27 test:65 字符的 PSR 组合超 64 上限,门禁 Attempt
以 StringDataRightTruncation 终态失败,Gate 收口为 blocked_retryable)。历史迁移
gw4d5e6f7g8h 仅做了 run_no→source_run_no 改名、漏了加宽,本迁移补齐。
注意:downgrade 收窄前须确认不存在长度 >64 的行,否则将失败(不做静默截断,
标识符截断会破坏与 RPA Worker 的精确回关联)。
"""
from __future__ import annotations
from alembic import op
import sqlalchemy as sa
revision = "we9f0a1b2c3d"
down_revision = "wd7e8f9a0b1c"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.alter_column(
"shipping_task_inventory_rpa_attempts",
"source_run_no",
existing_type=sa.String(length=64),
type_=sa.String(length=128),
existing_nullable=False,
)
def downgrade() -> None:
op.alter_column(
"shipping_task_inventory_rpa_attempts",
"source_run_no",
existing_type=sa.String(length=128),
type_=sa.String(length=64),
existing_nullable=False,
)