Files
junhong_cmp_fiber/migrations/000177_add_agent_wallet_refund_unique.down.sql
2026-07-24 16:07:18 +08:00

21 lines
545 B
PL/PgSQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
BEGIN;
-- 停止退款生产者后在同一事务锁定资金流水与 Outbox避免检查和删索引之间提交新事实。
LOCK TABLE tb_agent_wallet_transaction, tb_outbox_event IN ACCESS EXCLUSIVE MODE;
DO $$
BEGIN
IF EXISTS (
SELECT 1
FROM tb_outbox_event
WHERE event_type = 'wallet.agent_main.refunded'
) THEN
RAISE EXCEPTION '已存在代理主钱包统一退款事实,禁止移除退款防重约束';
END IF;
END
$$;
DROP INDEX IF EXISTS uq_agent_wallet_refund_reference;
COMMIT;