Merge remote-tracking branch 'origin/test' into dev
# Conflicts: # deploy/sql/头程数据库统一增量-MySQL8.sql
This commit is contained in:
@@ -2593,6 +2593,7 @@ CREATE TABLE IF NOT EXISTS fl_inbound_order (
|
||||
KEY idx_inbound_arrival (tenant_id, expected_arrival_at),
|
||||
KEY idx_inbound_destination (tenant_id, destination_code, created_at),
|
||||
KEY idx_inbound_channel (tenant_id, channel_code, created_at),
|
||||
KEY idx_inbound_smart_loading (warehouse_id, process_status, channel_code, expected_arrival_at, id),
|
||||
CONSTRAINT fk_inbound_task FOREIGN KEY (task_id) REFERENCES fl_fulfillment_task (id)
|
||||
) ENGINE=InnoDB COMMENT='二期头程入库单聚合根和列表查询快照';
|
||||
|
||||
@@ -2773,6 +2774,7 @@ CREATE TABLE IF NOT EXISTS fl_inbound_measurement (
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY uk_measure_external_event (tenant_id, source_code, external_event_no),
|
||||
KEY idx_measure_inbound_time (tenant_id, inbound_id, created_at),
|
||||
KEY idx_measure_inbound_status_id (tenant_id, inbound_id, status, id),
|
||||
CONSTRAINT fk_measure_inbound FOREIGN KEY (inbound_id) REFERENCES fl_inbound_order (id)
|
||||
) ENGINE=InnoDB COMMENT='入库长宽高测量批次和第三方原始数据';
|
||||
|
||||
@@ -2815,6 +2817,7 @@ CREATE TABLE IF NOT EXISTS fl_inbound_measurement_item (
|
||||
UNIQUE KEY uk_measure_item_no (tenant_id, measurement_id, item_no),
|
||||
UNIQUE KEY uk_measure_external_detail (tenant_id, inbound_detail_id, external_detail_no),
|
||||
UNIQUE KEY uk_measure_box_code (tenant_id, box_code),
|
||||
KEY idx_measure_item_candidate (tenant_id, measurement_id, inbound_detail_id),
|
||||
CONSTRAINT fk_measure_item_batch FOREIGN KEY (measurement_id) REFERENCES fl_inbound_measurement (id)
|
||||
) ENGINE=InnoDB COMMENT='入库长宽高和箱数测量明细';
|
||||
|
||||
@@ -5194,6 +5197,7 @@ CREATE TABLE IF NOT EXISTS fl_loading_plan_item (
|
||||
KEY idx_loading_item_plan (loading_plan_id, deleted, load_sequence, id),
|
||||
KEY idx_loading_item_account (account_id, created_at, id),
|
||||
KEY idx_loading_item_inbound (account_id, inbound_id, deleted),
|
||||
KEY idx_loading_item_candidate (account_id, inbound_id, inbound_detail_id, deleted),
|
||||
KEY idx_loading_item_order (account_id, order_id, deleted),
|
||||
CONSTRAINT fk_loading_item_plan FOREIGN KEY (loading_plan_id) REFERENCES fl_loading_plan (id),
|
||||
CONSTRAINT chk_loading_item_account CHECK (account_id > 0),
|
||||
@@ -8573,6 +8577,7 @@ CREATE TABLE IF NOT EXISTS fl_inbound_split_item (
|
||||
UNIQUE KEY uk_inbound_split_batch_line (tenant_id, split_batch_id, line_no),
|
||||
UNIQUE KEY uk_inbound_split_batch_source_child (tenant_id, split_batch_id, source_measurement_item_id, child_inbound_id),
|
||||
KEY idx_inbound_split_detail (tenant_id, source_inbound_detail_id, created_at),
|
||||
KEY idx_inbound_split_candidate (tenant_id, parent_inbound_id, source_inbound_detail_id),
|
||||
CONSTRAINT chk_inbound_split_item_package CHECK (package_count > 0),
|
||||
CONSTRAINT fk_inbound_split_item_batch FOREIGN KEY (split_batch_id) REFERENCES fl_inbound_split_batch (id),
|
||||
CONSTRAINT fk_inbound_split_item_parent FOREIGN KEY (parent_inbound_id) REFERENCES fl_inbound_order (id),
|
||||
@@ -17307,6 +17312,40 @@ CALL auth_backfill_login_phone();
|
||||
DROP PROCEDURE auth_backfill_login_phone;
|
||||
|
||||
USE baiyue_firstleg;
|
||||
DROP PROCEDURE IF EXISTS baiyue_firstleg.ensure_smart_loading_candidate_indexes;
|
||||
DELIMITER $$
|
||||
CREATE PROCEDURE baiyue_firstleg.ensure_smart_loading_candidate_indexes()
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_inbound_order' AND index_name='idx_inbound_smart_loading') THEN
|
||||
ALTER TABLE baiyue_firstleg.fl_inbound_order
|
||||
ADD KEY idx_inbound_smart_loading (warehouse_id,process_status,channel_code,expected_arrival_at,id);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_inbound_measurement' AND index_name='idx_measure_inbound_status_id') THEN
|
||||
ALTER TABLE baiyue_firstleg.fl_inbound_measurement
|
||||
ADD KEY idx_measure_inbound_status_id (tenant_id,inbound_id,status,id);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_inbound_measurement_item' AND index_name='idx_measure_item_candidate') THEN
|
||||
ALTER TABLE baiyue_firstleg.fl_inbound_measurement_item
|
||||
ADD KEY idx_measure_item_candidate (tenant_id,measurement_id,inbound_detail_id);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_loading_plan_item' AND index_name='idx_loading_item_candidate') THEN
|
||||
ALTER TABLE baiyue_firstleg.fl_loading_plan_item
|
||||
ADD KEY idx_loading_item_candidate (account_id,inbound_id,inbound_detail_id,deleted);
|
||||
END IF;
|
||||
IF NOT EXISTS (SELECT 1 FROM information_schema.statistics WHERE table_schema='baiyue_firstleg'
|
||||
AND table_name='fl_inbound_split_item' AND index_name='idx_inbound_split_candidate') THEN
|
||||
ALTER TABLE baiyue_firstleg.fl_inbound_split_item
|
||||
ADD KEY idx_inbound_split_candidate (tenant_id,parent_inbound_id,source_inbound_detail_id);
|
||||
END IF;
|
||||
END$$
|
||||
DELIMITER ;
|
||||
CALL baiyue_firstleg.ensure_smart_loading_candidate_indexes();
|
||||
DROP PROCEDURE IF EXISTS baiyue_firstleg.ensure_smart_loading_candidate_indexes;
|
||||
|
||||
CALL baiyue_firstleg.assert_unified_final_schema();
|
||||
DROP PROCEDURE IF EXISTS baiyue_firstleg.assert_unified_final_schema;
|
||||
SELECT 'PASS' AS migration_status,
|
||||
|
||||
Reference in New Issue
Block a user