diff --git a/deploy/sql/头程数据库统一增量-MySQL8.sql b/deploy/sql/头程数据库统一增量-MySQL8.sql index 847dae411..776b0e0b1 100644 --- a/deploy/sql/头程数据库统一增量-MySQL8.sql +++ b/deploy/sql/头程数据库统一增量-MySQL8.sql @@ -5485,6 +5485,7 @@ BEGIN DECLARE source_exists INT DEFAULT 0; DECLARE source_total_columns INT DEFAULT 0; DECLARE source_smart_columns INT DEFAULT 0; + DECLARE source_current_columns INT DEFAULT 0; DECLARE source_inbound_columns INT DEFAULT 0; DECLARE target_exists INT DEFAULT 0; DECLARE target_total_columns INT DEFAULT 0; @@ -5529,7 +5530,45 @@ BEGIN OR (column_name = 'updated_at' AND data_type = 'datetime' AND datetime_precision = 3 AND is_nullable = 'NO' AND LOWER(column_default) LIKE 'current_timestamp%' AND LOWER(extra) LIKE '%on update current_timestamp%') ); - IF source_total_columns = 11 AND source_smart_columns = 11 AND source_inbound_columns < 12 + SELECT COUNT(*) INTO source_current_columns + FROM information_schema.columns + WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' AND ( + (column_name = 'id' AND LOWER(column_type) = 'bigint unsigned' AND is_nullable = 'NO') + OR (column_name = 'loading_plan_id' AND LOWER(column_type) = 'bigint unsigned' AND is_nullable = 'NO') + 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(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%') + OR (column_name = 'completed_by' AND LOWER(column_type) = 'bigint unsigned' AND is_nullable = 'YES') + OR (column_name = 'completed_by_name' AND LOWER(column_type) = 'varchar(64)' AND is_nullable = 'YES') + OR (column_name = 'completed_at' AND data_type = 'datetime' AND datetime_precision = 3 AND is_nullable = 'YES') + OR (column_name = 'version' AND LOWER(column_type) = 'int unsigned' AND is_nullable = 'NO' AND CAST(column_default AS CHAR) = '0') + ); + + IF source_total_columns = 13 AND source_current_columns = 13 + AND (SELECT COUNT(*) FROM information_schema.statistics + WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' + AND index_name = 'uk_loading_pick_task_plan' AND non_unique = 0 + AND seq_in_index = 1 AND column_name = 'loading_plan_id') = 1 + AND (SELECT COUNT(*) FROM information_schema.statistics + WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' + AND index_name = 'uk_loading_pick_task_booking' AND non_unique = 0 + AND seq_in_index = 1 AND column_name = 'container_booking_id') = 1 + AND (SELECT COUNT(*) FROM information_schema.statistics + WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' + AND index_name = 'idx_loading_pick_container' + AND ((seq_in_index = 1 AND column_name = 'container_no') + OR (seq_in_index = 2 AND column_name = 'task_status') + OR (seq_in_index = 3 AND column_name = 'started_at'))) = 3 + AND (SELECT COUNT(*) FROM information_schema.key_column_usage + WHERE constraint_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' + AND column_name = 'loading_plan_id' AND referenced_table_name = 'fl_loading_plan' + AND referenced_column_name = 'id') = 1 THEN + SET source_exists = 1; + ELSEIF source_total_columns = 11 AND source_smart_columns = 11 AND source_inbound_columns < 12 AND (SELECT COUNT(*) FROM information_schema.statistics WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' AND index_name = 'uk_loading_pick_task_plan' AND non_unique = 0 @@ -5843,6 +5882,29 @@ DELIMITER ; CALL repair_phase3_loading_pick_task_foreign_keys(); DROP PROCEDURE repair_phase3_loading_pick_task_foreign_keys; +-- Existing deployments may predate simulated-container channel grouping. The +-- update trigger below references this column, so upgrade it before compiling +-- the trigger rather than waiting for the later channel-container data block. +DROP PROCEDURE IF EXISTS phase3_add_container_channel_group; +DELIMITER $$ +CREATE PROCEDURE phase3_add_container_channel_group() +BEGIN + IF NOT EXISTS ( + SELECT 1 FROM information_schema.columns + WHERE table_schema = 'baiyue_firstleg' + AND table_name = 'fl_container_booking' + AND column_name = 'channel_group_code' + ) THEN + ALTER TABLE fl_container_booking + ADD COLUMN channel_group_code VARCHAR(64) NULL + COMMENT '模拟柜计划渠道分组;关联真实订舱后继续保留' + AFTER merged_into_container_booking_id; + END IF; +END$$ +DELIMITER ; +CALL phase3_add_container_channel_group(); +DROP PROCEDURE phase3_add_container_channel_group; + DROP TRIGGER IF EXISTS trg_container_booking_before_update; DELIMITER $$ CREATE TRIGGER trg_container_booking_before_update @@ -6451,14 +6513,13 @@ FROM iam_role role JOIN iam_permission permission ON permission.tenant_id = 0 AND permission.permission_code IN ( - 'platform:firstleg:container:list', 'platform:firstleg:container:view', + 'platform:firstleg:container:list', 'platform:firstleg:container:create', 'platform:firstleg:container:edit', 'platform:firstleg:smart-loading:list', 'platform:firstleg:smart-loading:assign', 'platform:firstleg:smart-loading:delete', - 'platform:firstleg:preload:list', 'platform:firstleg:preload:view', + 'platform:firstleg:preload:list', 'platform:firstleg:preload:edit', 'platform:firstleg:preload:complete', - 'platform:firstleg:preload:confirm', 'platform:firstleg:loading-list:list', - 'platform:firstleg:loading-list:view') + 'platform:firstleg:preload:confirm', 'platform:firstleg:loading-list:list') WHERE role.tenant_id = 0 AND role.role_code IN ('PLATFORM_ADMIN', 'ORDER_OPERATOR'); @@ -6583,13 +6644,13 @@ BEGIN IF (SELECT COUNT(DISTINCT permission_code) FROM baiyue_iam.iam_permission WHERE tenant_id = 0 AND app_code = 'PLATFORM' AND status = 'ACTIVE' AND deleted = 0 AND permission_code IN ( - 'platform:firstleg:container:list', 'platform:firstleg:container:view', + 'platform:firstleg:container:list', 'platform:firstleg:container:create', 'platform:firstleg:container:edit', 'platform:firstleg:smart-loading:list', 'platform:firstleg:smart-loading:assign', 'platform:firstleg:smart-loading:delete', 'platform:firstleg:preload:list', - 'platform:firstleg:preload:view', 'platform:firstleg:preload:edit', + 'platform:firstleg:preload:edit', 'platform:firstleg:preload:complete', 'platform:firstleg:preload:confirm', - 'platform:firstleg:loading-list:list', 'platform:firstleg:loading-list:view')) <> 14 THEN + 'platform:firstleg:loading-list:list')) <> 11 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = '智能装柜迁移失败:平台权限资源未完整创建'; END IF; IF (SELECT COUNT(DISTINCT CONCAT(role.role_code, ':', permission.permission_code)) @@ -6599,14 +6660,13 @@ BEGIN WHERE role.tenant_id = 0 AND role.role_code IN ('PLATFORM_ADMIN', 'ORDER_OPERATOR') AND permission.tenant_id = 0 AND permission.permission_code IN ( - 'platform:firstleg:container:list', 'platform:firstleg:container:view', + 'platform:firstleg:container:list', 'platform:firstleg:container:create', 'platform:firstleg:container:edit', 'platform:firstleg:smart-loading:list', 'platform:firstleg:smart-loading:assign', 'platform:firstleg:smart-loading:delete', - 'platform:firstleg:preload:list', 'platform:firstleg:preload:view', + 'platform:firstleg:preload:list', 'platform:firstleg:preload:edit', 'platform:firstleg:preload:complete', - 'platform:firstleg:preload:confirm', 'platform:firstleg:loading-list:list', - 'platform:firstleg:loading-list:view')) <> 28 THEN + 'platform:firstleg:preload:confirm', 'platform:firstleg:loading-list:list')) <> 22 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = '智能装柜迁移失败:平台角色授权未完整写入'; END IF; END$$ @@ -13773,6 +13833,7 @@ CALL queue_column_comment('baiyue_firstleg', 'fl_carrier_schedule_query_operatio CALL queue_column_comment('baiyue_firstleg', 'fl_carrier_schedule_query_operation', 'status', '处理状态:PROCESSING处理中、SUCCESS成功'); CALL queue_column_comment('baiyue_firstleg', 'fl_carrier_schedule_node_fact', 'id', '标准船节点事实ID'); CALL queue_column_comment('baiyue_firstleg', 'fl_carrier_schedule_node_fact', 'query_id', '所属查询任务ID'); +CALL queue_column_comment('baiyue_firstleg', 'fl_carrier_schedule_node_fact', 'container_booking_id', '所属真实货柜ID'); CALL queue_column_comment('baiyue_firstleg', 'fl_carrier_schedule_node_fact', 'event_key', '供应商编码与供应商事件ID组成的幂等键'); CALL queue_column_comment('baiyue_firstleg', 'fl_carrier_schedule_node_fact', 'provider_code', '轨迹供应商编码'); CALL queue_column_comment('baiyue_firstleg', 'fl_carrier_schedule_node_fact', 'provider_event_id', '供应商稳定事件ID'); @@ -15955,6 +16016,24 @@ BEGIN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = '统一迁移失败:客户四箱规尺寸配置字段不完整'; END IF; + IF (SELECT COUNT(*) FROM information_schema.columns + WHERE table_schema = 'baiyue_firstleg' + AND table_name = 'fl_customer_charge_rule' + AND column_name = 'initialization_key' + AND character_maximum_length = 128) <> 1 THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = '统一迁移失败:客户默认计费规则初始化幂等字段未创建'; + END IF; + IF (SELECT COUNT(*) FROM information_schema.statistics + WHERE table_schema = 'baiyue_firstleg' + AND table_name = 'fl_customer_charge_rule' + AND index_name = 'idx_charge_rule_initialization' + AND non_unique = 1 + AND ((seq_in_index = 1 AND column_name = 'tenant_id') + OR (seq_in_index = 2 AND column_name = 'initialization_key'))) <> 2 THEN + SIGNAL SQLSTATE '45000' + SET MESSAGE_TEXT = '统一迁移失败:客户默认计费规则初始化索引未完整创建'; + END IF; IF EXISTS ( SELECT tenant.id FROM baiyue_iam.iam_tenant tenant diff --git a/firstleg/src/main/resources/db/phase3-smart-loading-schema.sql b/firstleg/src/main/resources/db/phase3-smart-loading-schema.sql index 45ae823fe..8245dbde0 100644 --- a/firstleg/src/main/resources/db/phase3-smart-loading-schema.sql +++ b/firstleg/src/main/resources/db/phase3-smart-loading-schema.sql @@ -466,6 +466,7 @@ BEGIN DECLARE source_exists INT DEFAULT 0; DECLARE source_total_columns INT DEFAULT 0; DECLARE source_smart_columns INT DEFAULT 0; + DECLARE source_current_columns INT DEFAULT 0; DECLARE source_inbound_columns INT DEFAULT 0; DECLARE target_exists INT DEFAULT 0; DECLARE target_total_columns INT DEFAULT 0; @@ -510,7 +511,45 @@ BEGIN OR (column_name = 'updated_at' AND data_type = 'datetime' AND datetime_precision = 3 AND is_nullable = 'NO' AND LOWER(column_default) LIKE 'current_timestamp%' AND LOWER(extra) LIKE '%on update current_timestamp%') ); - IF source_total_columns = 11 AND source_smart_columns = 11 AND source_inbound_columns < 12 + SELECT COUNT(*) INTO source_current_columns + FROM information_schema.columns + WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' AND ( + (column_name = 'id' AND LOWER(column_type) = 'bigint unsigned' AND is_nullable = 'NO') + OR (column_name = 'loading_plan_id' AND LOWER(column_type) = 'bigint unsigned' AND is_nullable = 'NO') + 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(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%') + OR (column_name = 'completed_by' AND LOWER(column_type) = 'bigint unsigned' AND is_nullable = 'YES') + OR (column_name = 'completed_by_name' AND LOWER(column_type) = 'varchar(64)' AND is_nullable = 'YES') + OR (column_name = 'completed_at' AND data_type = 'datetime' AND datetime_precision = 3 AND is_nullable = 'YES') + OR (column_name = 'version' AND LOWER(column_type) = 'int unsigned' AND is_nullable = 'NO' AND CAST(column_default AS CHAR) = '0') + ); + + IF source_total_columns = 13 AND source_current_columns = 13 + AND (SELECT COUNT(*) FROM information_schema.statistics + WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' + AND index_name = 'uk_loading_pick_task_plan' AND non_unique = 0 + AND seq_in_index = 1 AND column_name = 'loading_plan_id') = 1 + AND (SELECT COUNT(*) FROM information_schema.statistics + WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' + AND index_name = 'uk_loading_pick_task_booking' AND non_unique = 0 + AND seq_in_index = 1 AND column_name = 'container_booking_id') = 1 + AND (SELECT COUNT(*) FROM information_schema.statistics + WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' + AND index_name = 'idx_loading_pick_container' + AND ((seq_in_index = 1 AND column_name = 'container_no') + OR (seq_in_index = 2 AND column_name = 'task_status') + OR (seq_in_index = 3 AND column_name = 'started_at'))) = 3 + AND (SELECT COUNT(*) FROM information_schema.key_column_usage + WHERE constraint_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' + AND column_name = 'loading_plan_id' AND referenced_table_name = 'fl_loading_plan' + AND referenced_column_name = 'id') = 1 THEN + SET source_exists = 1; + ELSEIF source_total_columns = 11 AND source_smart_columns = 11 AND source_inbound_columns < 12 AND (SELECT COUNT(*) FROM information_schema.statistics WHERE table_schema = 'baiyue_firstleg' AND table_name = 'fl_loading_pick_task' AND index_name = 'uk_loading_pick_task_plan' AND non_unique = 0 @@ -1431,14 +1470,13 @@ FROM iam_role role JOIN iam_permission permission ON permission.tenant_id = 0 AND permission.permission_code IN ( - 'platform:firstleg:container:list', 'platform:firstleg:container:view', + 'platform:firstleg:container:list', 'platform:firstleg:container:create', 'platform:firstleg:container:edit', 'platform:firstleg:smart-loading:list', 'platform:firstleg:smart-loading:assign', 'platform:firstleg:smart-loading:delete', - 'platform:firstleg:preload:list', 'platform:firstleg:preload:view', + 'platform:firstleg:preload:list', 'platform:firstleg:preload:edit', 'platform:firstleg:preload:complete', - 'platform:firstleg:preload:confirm', 'platform:firstleg:loading-list:list', - 'platform:firstleg:loading-list:view') + 'platform:firstleg:preload:confirm', 'platform:firstleg:loading-list:list') WHERE role.tenant_id = 0 AND role.role_code IN ('PLATFORM_ADMIN', 'ORDER_OPERATOR'); @@ -1563,13 +1601,13 @@ BEGIN IF (SELECT COUNT(DISTINCT permission_code) FROM baiyue_iam.iam_permission WHERE tenant_id = 0 AND app_code = 'PLATFORM' AND status = 'ACTIVE' AND deleted = 0 AND permission_code IN ( - 'platform:firstleg:container:list', 'platform:firstleg:container:view', + 'platform:firstleg:container:list', 'platform:firstleg:container:create', 'platform:firstleg:container:edit', 'platform:firstleg:smart-loading:list', 'platform:firstleg:smart-loading:assign', 'platform:firstleg:smart-loading:delete', 'platform:firstleg:preload:list', - 'platform:firstleg:preload:view', 'platform:firstleg:preload:edit', + 'platform:firstleg:preload:edit', 'platform:firstleg:preload:complete', 'platform:firstleg:preload:confirm', - 'platform:firstleg:loading-list:list', 'platform:firstleg:loading-list:view')) <> 14 THEN + 'platform:firstleg:loading-list:list')) <> 11 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = '智能装柜迁移失败:平台权限资源未完整创建'; END IF; IF (SELECT COUNT(DISTINCT CONCAT(role.role_code, ':', permission.permission_code)) @@ -1579,14 +1617,13 @@ BEGIN WHERE role.tenant_id = 0 AND role.role_code IN ('PLATFORM_ADMIN', 'ORDER_OPERATOR') AND permission.tenant_id = 0 AND permission.permission_code IN ( - 'platform:firstleg:container:list', 'platform:firstleg:container:view', + 'platform:firstleg:container:list', 'platform:firstleg:container:create', 'platform:firstleg:container:edit', 'platform:firstleg:smart-loading:list', 'platform:firstleg:smart-loading:assign', 'platform:firstleg:smart-loading:delete', - 'platform:firstleg:preload:list', 'platform:firstleg:preload:view', + 'platform:firstleg:preload:list', 'platform:firstleg:preload:edit', 'platform:firstleg:preload:complete', - 'platform:firstleg:preload:confirm', 'platform:firstleg:loading-list:list', - 'platform:firstleg:loading-list:view')) <> 28 THEN + 'platform:firstleg:preload:confirm', 'platform:firstleg:loading-list:list')) <> 22 THEN SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = '智能装柜迁移失败:平台角色授权未完整写入'; END IF; END$$ diff --git a/firstleg/src/test/java/com/baiyue/firstleg/repository/CustomerDimensionConfigSqlContractTest.java b/firstleg/src/test/java/com/baiyue/firstleg/repository/CustomerDimensionConfigSqlContractTest.java index 783615014..aec810024 100644 --- a/firstleg/src/test/java/com/baiyue/firstleg/repository/CustomerDimensionConfigSqlContractTest.java +++ b/firstleg/src/test/java/com/baiyue/firstleg/repository/CustomerDimensionConfigSqlContractTest.java @@ -115,6 +115,9 @@ class CustomerDimensionConfigSqlContractTest { .contains("r.role_code = 'ORDER_OPERATOR'") .contains("index_name = 'uk_customer_dimension_config_tenant_box'") .contains("客户四箱规尺寸配置字段不完整") + .contains("客户默认计费规则初始化幂等字段未创建") + .contains("index_name = 'idx_charge_rule_initialization'") + .contains("客户默认计费规则初始化索引未完整创建") .contains("客户尺寸计算配置权限码、固定ID或父节点不正确"); } diff --git a/firstleg/src/test/java/com/baiyue/firstleg/repository/Phase3FinalUnifiedSqlContractTest.java b/firstleg/src/test/java/com/baiyue/firstleg/repository/Phase3FinalUnifiedSqlContractTest.java index b84c6a04f..2d812a167 100644 --- a/firstleg/src/test/java/com/baiyue/firstleg/repository/Phase3FinalUnifiedSqlContractTest.java +++ b/firstleg/src/test/java/com/baiyue/firstleg/repository/Phase3FinalUnifiedSqlContractTest.java @@ -188,7 +188,8 @@ class Phase3FinalUnifiedSqlContractTest { assertThat(sql) .contains("CALL queue_column_comment('baiyue_firstleg', 'fl_inbound_fee_detail', 'supplier_id'") .contains("CALL queue_column_comment('baiyue_firstleg', 'fl_inbound_fee_detail', 'supplier_name'") - .contains("CALL queue_column_comment('baiyue_firstleg', 'fl_inbound_fee_detail', 'supplier_category'"); + .contains("CALL queue_column_comment('baiyue_firstleg', 'fl_inbound_fee_detail', 'supplier_category'") + .contains("CALL queue_column_comment('baiyue_firstleg', 'fl_carrier_schedule_node_fact', 'container_booking_id'"); assertThat(sql.indexOf("CALL apply_queued_comments();", sql.indexOf("-- END GENERATED NINE-SCHEMA COMMENT UPGRADE CALLS"))) .isGreaterThan(sql.indexOf("-- END GENERATED NINE-SCHEMA COMMENT UPGRADE CALLS")); diff --git a/firstleg/src/test/java/com/baiyue/firstleg/repository/SmartLoadingSqlContractTest.java b/firstleg/src/test/java/com/baiyue/firstleg/repository/SmartLoadingSqlContractTest.java index 909474e2d..5a024d6e5 100644 --- a/firstleg/src/test/java/com/baiyue/firstleg/repository/SmartLoadingSqlContractTest.java +++ b/firstleg/src/test/java/com/baiyue/firstleg/repository/SmartLoadingSqlContractTest.java @@ -18,14 +18,14 @@ import static org.assertj.core.api.Assertions.assertThat; class SmartLoadingSqlContractTest { private static final Pattern PERMISSION_PATTERN = Pattern.compile("'((?:platform:firstleg:)[^']+)'"); private static final Set PHASE3_PERMISSIONS = Set.of( - "platform:firstleg:container:list", "platform:firstleg:container:view", + "platform:firstleg:container:list", "platform:firstleg:container:create", "platform:firstleg:container:edit", "platform:firstleg:smart-loading:list", "platform:firstleg:smart-loading:assign", "platform:firstleg:smart-loading:delete", "platform:firstleg:preload:list", - "platform:firstleg:preload:view", "platform:firstleg:preload:edit", + "platform:firstleg:preload:edit", "platform:firstleg:preload:complete", "platform:firstleg:preload:confirm", - "platform:firstleg:loading-list:list", "platform:firstleg:loading-list:view"); + "platform:firstleg:loading-list:list"); @Test @DisplayName("平台聚合与客户明细边界及原型快照字段完整") @@ -193,7 +193,7 @@ class SmartLoadingSqlContractTest { } @Test - @DisplayName("模块脚本和统一脚本均校验14项权限与两个角色28项授权") + @DisplayName("模块脚本和统一脚本均校验11项权限与两个角色22项授权") void shouldAssertCompletePermissionGrants() throws Exception { assertPermissionContract(migration()); assertPermissionContract(unifiedMigration()); @@ -238,6 +238,8 @@ class SmartLoadingSqlContractTest { .doesNotContain("WITHDRAWN"); assertLoadingCompletionTrigger(migration()); assertLoadingCompletionTrigger(unifiedMigration()); + assertThat(unifiedMigration().indexOf("CALL phase3_add_container_channel_group()")) + .isLessThan(unifiedMigration().indexOf("CREATE TRIGGER trg_container_booking_before_update")); } private static void assertLoadingCompletionTrigger(String sql) { @@ -266,6 +268,8 @@ class SmartLoadingSqlContractTest { assertThat(migration()) .contains("CREATE TABLE IF NOT EXISTS fl_loading_pick_task") .contains("CALL migrate_legacy_loading_pick_task()") + .contains("source_total_columns = 13 AND source_current_columns = 13") + .contains("index_name = 'uk_loading_pick_task_booking'") .contains("RENAME TABLE fl_loading_pick_task TO fl_inbound_loading_pick_task") .contains("CREATE TABLE IF NOT EXISTS fl_loading_pick_item") .contains("CREATE TABLE IF NOT EXISTS fl_loading_pick_history") @@ -371,7 +375,7 @@ class SmartLoadingSqlContractTest { int assertionStart = sql.lastIndexOf("IF (SELECT COUNT(DISTINCT CONCAT", message); String assertion = sql.substring(assertionStart, message); assertThat(permissions(assertion)).isEqualTo(PHASE3_PERMISSIONS); - assertThat(assertion).contains("<> 28 THEN"); + assertThat(assertion).contains("<> 22 THEN"); } private static Set permissions(String sql) {