Files
shanxia2.0/backend/scripts/migrate_20260808_crm_barrel_deposit.sql
T
2026-08-08 20:43:48 +08:00

20 lines
640 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.
-- 报价单/合同增加桶押金字段;合同从关联报价回填(仅 barrel_deposit=0 且有 quote_id)
ALTER TABLE `crm_quote`
ADD COLUMN `barrel_deposit` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '桶押金'
AFTER `freight`;
ALTER TABLE `crm_contract`
ADD COLUMN `barrel_deposit` decimal(18,2) NOT NULL DEFAULT 0.00 COMMENT '桶押金'
AFTER `freight`;
UPDATE `crm_contract` c
INNER JOIN `crm_quote` q
ON q.id = c.quote_id
AND q.tenant_no = c.tenant_no
AND q.del_flag = 0
SET c.barrel_deposit = IFNULL(q.barrel_deposit, 0)
WHERE c.del_flag = 0
AND c.quote_id IS NOT NULL
AND IFNULL(c.barrel_deposit, 0) = 0;