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);