20 lines
640 B
SQL
20 lines
640 B
SQL
-- 报价单/合同增加桶押金字段;合同从关联报价回填(仅 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;
|