From c9e5d65590089925fbf01d430e39d05e48b52844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E8=BF=9B?= Date: Mon, 26 Oct 2026 15:52:09 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=80=E6=AC=BE=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E5=B0=9D=E8=AF=95=E9=87=91=E9=A2=9D=E7=BA=A6=E6=9D=9F=E5=85=81?= =?UTF-8?q?=E8=AE=B8=200=20=E5=85=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 000218 的 chk_refund_request_attempt_amount 要求 refund_amount > 0,0 元退款提交审批报 SQLSTATE 23514。 生产库已人工放宽为 >= 0 但无迁移记录,测试库与新建库仍为 > 0。新增 000258 统一为 >= 0,生产执行后不变。 Co-Authored-By: Claude Opus 5.5 --- migrations/000258_allow_zero_refund_attempt_amount.down.sql | 4 ++++ migrations/000258_allow_zero_refund_attempt_amount.up.sql | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 migrations/000258_allow_zero_refund_attempt_amount.down.sql create mode 100644 migrations/000258_allow_zero_refund_attempt_amount.up.sql diff --git a/migrations/000258_allow_zero_refund_attempt_amount.down.sql b/migrations/000258_allow_zero_refund_attempt_amount.down.sql new file mode 100644 index 00000000..34a2518c --- /dev/null +++ b/migrations/000258_allow_zero_refund_attempt_amount.down.sql @@ -0,0 +1,4 @@ +-- 恢复为 refund_amount > 0。已存在 0 元审批尝试时不校验存量(NOT VALID),只约束之后写入的数据。 +ALTER TABLE tb_refund_request_attempt DROP CONSTRAINT IF EXISTS chk_refund_request_attempt_amount; +ALTER TABLE tb_refund_request_attempt + ADD CONSTRAINT chk_refund_request_attempt_amount CHECK (refund_amount > 0 AND frozen_actual_received_amount >= 0) NOT VALID; diff --git a/migrations/000258_allow_zero_refund_attempt_amount.up.sql b/migrations/000258_allow_zero_refund_attempt_amount.up.sql new file mode 100644 index 00000000..d85f1086 --- /dev/null +++ b/migrations/000258_allow_zero_refund_attempt_amount.up.sql @@ -0,0 +1,6 @@ +-- 允许 0 元退款的审批尝试金额(restore-zero-amount-refund)。 +-- 背景:000218 建表时约束为 refund_amount > 0,0 元退款(仅作废权益不退钱)提交审批时报 SQLSTATE 23514; +-- 生产库已人工放宽为 >= 0 但没有迁移记录,测试库与新建库仍为 > 0。本迁移把约束统一为 >= 0,生产执行后结果不变。 +ALTER TABLE tb_refund_request_attempt DROP CONSTRAINT IF EXISTS chk_refund_request_attempt_amount; +ALTER TABLE tb_refund_request_attempt + ADD CONSTRAINT chk_refund_request_attempt_amount CHECK (refund_amount >= 0 AND frozen_actual_received_amount >= 0);