Files
baiyue-firstleg/firstleg/src/main/resources/db/phase3-inbounded-status-unification.sql
T
2026-08-13 09:49:55 +08:00

22 lines
979 B
SQL

-- 新完成入库记录使用 WAIT_SPLIT,存量 INBOUNDED 继续作为可分柜兼容状态。
-- 本脚本不改写业务主表或历史状态,避免影响既有审计记录。
USE baiyue_firstleg;
DROP PROCEDURE IF EXISTS assert_inbounded_compatibility;
DELIMITER $$
CREATE PROCEDURE assert_inbounded_compatibility()
BEGIN
IF (SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_inbound_order'
AND column_name = 'process_status') <> 1
OR (SELECT COUNT(*) FROM information_schema.columns
WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_inbound_status_history'
AND column_name IN ('from_status', 'to_status')) <> 2 THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'WAIT_SPLIT/INBOUNDED 兼容校验失败:入库状态字段不完整';
END IF;
END$$
DELIMITER ;
CALL assert_inbounded_compatibility();
DROP PROCEDURE assert_inbounded_compatibility;