优化
This commit is contained in:
@@ -5216,7 +5216,7 @@ BEGIN
|
||||
OR (column_name = 'container_booking_id' AND LOWER(column_type) = 'bigint unsigned' AND is_nullable = 'NO')
|
||||
OR (column_name = 'cabinet_no' AND LOWER(column_type) = 'varchar(64)' AND is_nullable = 'NO')
|
||||
OR (column_name = 'container_no' AND LOWER(column_type) = 'varchar(64)' AND is_nullable = 'YES')
|
||||
OR (column_name = 'task_status' AND LOWER(column_type) = 'varchar(16)' AND is_nullable = 'NO' AND column_default = 'LOADING')
|
||||
OR (column_name = 'task_status' AND LOWER(column_type) = 'varchar(24)' AND is_nullable = 'NO' AND column_default = 'LOADING')
|
||||
OR (column_name = 'started_by' AND LOWER(column_type) = 'bigint unsigned' AND is_nullable = 'NO')
|
||||
OR (column_name = 'started_by_name' AND LOWER(column_type) = 'varchar(64)' AND is_nullable = 'YES')
|
||||
OR (column_name = 'started_at' AND data_type = 'datetime' AND datetime_precision = 3 AND is_nullable = 'NO' AND LOWER(column_default) LIKE 'current_timestamp%')
|
||||
@@ -15471,20 +15471,6 @@ WHERE tenant_id=0 AND app_code='PLATFORM'
|
||||
CALL assert_loading_pick_task_shapes(1);
|
||||
DROP PROCEDURE IF EXISTS assert_loading_pick_task_shapes;
|
||||
|
||||
-- 修复旧版本“推送预装即拣货中”的状态污染;从未实际拣货的计划回收到预装柜中。
|
||||
UPDATE fl_loading_plan plan
|
||||
SET plan_status = 'EDITING',
|
||||
updated_at = CURRENT_TIMESTAMP(3),
|
||||
version = version + 1
|
||||
WHERE plan.plan_status = 'LOADING'
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM fl_loading_pick_item pick_item
|
||||
JOIN fl_loading_pick_task pick_task ON pick_task.id = pick_item.pick_task_id
|
||||
WHERE pick_task.loading_plan_id = plan.id
|
||||
AND pick_item.picked_package_count > 0
|
||||
);
|
||||
|
||||
/* Phase 3 channel-owned containers and stable PDA identity. Source: firstleg phase3-channel-container-migration.sql */
|
||||
DROP PROCEDURE IF EXISTS migrate_phase3_channel_containers;
|
||||
DELIMITER $$
|
||||
@@ -15648,6 +15634,42 @@ CREATE TABLE IF NOT EXISTS baiyue_firstleg.fl_container_transport_history (
|
||||
KEY idx_container_transport_history(container_booking_id,created_at,id)
|
||||
) ENGINE=InnoDB COMMENT='柜次真实运输字段不可变变更审计';
|
||||
|
||||
DROP PROCEDURE IF EXISTS baiyue_firstleg.ensure_container_transport_history_schema;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE baiyue_firstleg.ensure_container_transport_history_schema()
|
||||
BEGIN
|
||||
IF (NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_container_transport_history' AND column_name='operation_id')
|
||||
OR NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_container_transport_history' AND column_name='request_hash'))
|
||||
AND EXISTS (SELECT 1 FROM baiyue_firstleg.fl_container_transport_history LIMIT 1) THEN
|
||||
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT='运输历史升级失败:旧表已有数据且缺少幂等字段';
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_container_transport_history' AND column_name='operation_id') THEN
|
||||
ALTER TABLE baiyue_firstleg.fl_container_transport_history
|
||||
ADD COLUMN operation_id VARCHAR(64) NOT NULL COMMENT '运输字段操作幂等ID' AFTER after_voyage_no;
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_container_transport_history' AND column_name='request_hash') THEN
|
||||
ALTER TABLE baiyue_firstleg.fl_container_transport_history
|
||||
ADD COLUMN request_hash CHAR(64) NOT NULL COMMENT '运输字段请求哈希' AFTER operation_id;
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_container_transport_history' AND index_name='uk_container_transport_history_operation') THEN
|
||||
ALTER TABLE baiyue_firstleg.fl_container_transport_history
|
||||
ADD UNIQUE KEY uk_container_transport_history_operation (container_booking_id,operator_id,operation_id);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_container_transport_history' AND index_name='idx_container_transport_history') THEN
|
||||
ALTER TABLE baiyue_firstleg.fl_container_transport_history
|
||||
ADD KEY idx_container_transport_history (container_booking_id,created_at,id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
CALL baiyue_firstleg.ensure_container_transport_history_schema();
|
||||
DROP PROCEDURE baiyue_firstleg.ensure_container_transport_history_schema;
|
||||
|
||||
ALTER TABLE baiyue_firstleg.fl_container_transport_history
|
||||
MODIFY COLUMN id BIGINT UNSIGNED NOT NULL COMMENT '运输字段变更历史ID',
|
||||
MODIFY COLUMN container_booking_id BIGINT UNSIGNED NOT NULL COMMENT '稳定柜次ID',
|
||||
|
||||
Reference in New Issue
Block a user