Files
junhong_cmp_fiber/migrations/000190_add_agent_recharge_approval_instance.up.sql
break 73f5125d3d
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
七月迭代短暂完结,还有很多后端的关键东西没有弄,这是一版赶时间做的东西
2026-07-25 17:06:58 +08:00

21 lines
818 B
SQL
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.
-- 为员工线下代充值关联唯一通用审批实例。
ALTER TABLE tb_agent_recharge_record
ADD COLUMN IF NOT EXISTS approval_instance_id bigint;
CREATE UNIQUE INDEX IF NOT EXISTS uq_agent_recharge_approval_instance
ON tb_agent_recharge_record (approval_instance_id)
WHERE approval_instance_id IS NOT NULL;
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_constraint WHERE conname = 'chk_agent_recharge_approval_instance'
) THEN
ALTER TABLE tb_agent_recharge_record
ADD CONSTRAINT chk_agent_recharge_approval_instance
CHECK (approval_instance_id IS NULL OR approval_instance_id > 0);
END IF;
END $$;
COMMENT ON COLUMN tb_agent_recharge_record.approval_instance_id IS '员工线下代充值关联的唯一通用审批实例 ID在线充值为空';