优化
This commit is contained in:
@@ -868,6 +868,23 @@ DELIMITER $$
|
||||
CREATE PROCEDURE relocate_legacy_inbound_loading_permissions()
|
||||
BEGIN
|
||||
DECLARE legacy_count INT DEFAULT 0;
|
||||
IF EXISTS (
|
||||
SELECT 1 FROM iam_permission
|
||||
WHERE id IN (5102091, 5102092, 5102093, 5102094, 5102096, 5102097, 5102098, 5102099)
|
||||
AND permission_code NOT IN (
|
||||
'platform:firstleg:container:view', 'platform:firstleg:container:create',
|
||||
'platform:firstleg:container:edit', 'platform:firstleg:smart-loading:list',
|
||||
'platform:firstleg:smart-loading:create', 'platform:firstleg:smart-loading:assign',
|
||||
'platform:firstleg:smart-loading:delete', 'platform:firstleg:smart-loading:push',
|
||||
'firstleg:inbound:split', 'firstleg:inbound:preload', 'firstleg:inbound:preload-view',
|
||||
'platform:firstleg:inbound:loading:edit', 'platform:firstleg:inbound:loading:view',
|
||||
'platform:firstleg:inbound:loading:complete', 'platform:firstleg:inbound:delivery:complete',
|
||||
'platform:firstleg:inbound:picking:edit', 'platform:firstleg:inbound:picking:view'
|
||||
)
|
||||
) THEN
|
||||
SIGNAL SQLSTATE '45000'
|
||||
SET MESSAGE_TEXT = '三期权限迁移失败:5102091-5102099 存在未知权限占用';
|
||||
END IF;
|
||||
SELECT COUNT(*) INTO legacy_count
|
||||
FROM iam_permission
|
||||
WHERE tenant_id = 0 AND app_code = 'PLATFORM'
|
||||
|
||||
+37
@@ -158,6 +158,15 @@ class SmartLoadingSqlContractTest {
|
||||
.isEqualTo(1);
|
||||
assertThat(count(unified, "SELECT 'PASS' AS migration_status"))
|
||||
.isEqualTo(1);
|
||||
int relocation = unified.indexOf("CALL unified_relocate_inbound_loading_permissions();");
|
||||
int assertion = unified.indexOf("CALL assert_phase3_smart_loading_schema();");
|
||||
assertThat(relocation).isGreaterThan(0);
|
||||
assertThat(assertion).isGreaterThan(relocation);
|
||||
assertThat(unified.substring(relocation, assertion))
|
||||
.contains("tmp_phase3_inbound_role_grant")
|
||||
.contains("DROP TEMPORARY TABLE IF EXISTS tmp_phase3_inbound_role_grant")
|
||||
.contains("5102121, 0, 'PLATFORM'")
|
||||
.contains("5102129, 0, 'PLATFORM'");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -180,6 +189,13 @@ class SmartLoadingSqlContractTest {
|
||||
.contains("KEY idx_loading_pick_status (tenant_id, status, updated_at)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("迁移拒绝缺列错类型和混合拣货表型")
|
||||
void shouldRejectMalformedLegacyPickTaskShapes() throws Exception {
|
||||
assertMalformedShapeGuards(migration());
|
||||
assertMalformedShapeGuards(unifiedMigration());
|
||||
}
|
||||
|
||||
private static String migration() throws Exception {
|
||||
return new ClassPathResource("db/phase3-smart-loading-schema.sql")
|
||||
.getContentAsString(StandardCharsets.UTF_8);
|
||||
@@ -213,6 +229,27 @@ class SmartLoadingSqlContractTest {
|
||||
return matcher.results().map(result -> result.group(1)).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private static void assertMalformedShapeGuards(String sql) {
|
||||
assertThat(sql)
|
||||
.containsAnyOf("source_total_columns = 11", "source_total = 11")
|
||||
.containsAnyOf("source_smart_columns = 11", "source_smart = 11")
|
||||
.containsAnyOf("source_total_columns = 12", "source_total = 12")
|
||||
.containsAnyOf("source_inbound_columns = 12", "source_inbound = 12")
|
||||
.contains("column_name = 'version'")
|
||||
.contains("column_name = 'remark'")
|
||||
.contains("column_name = 'updated_by'")
|
||||
.contains("column_name = 'updated_by_name'")
|
||||
.contains("column_name = 'created_at'")
|
||||
.contains("column_name = 'updated_at'")
|
||||
.contains("LOWER(column_type) = 'int'")
|
||||
.contains("LOWER(column_type) = 'int unsigned'")
|
||||
.contains("LOWER(extra) LIKE '%on update current_timestamp%'")
|
||||
.contains("uk_loading_pick_tenant_inbound")
|
||||
.contains("idx_loading_pick_status")
|
||||
.contains("referenced_table_name = 'fl_inbound_order'")
|
||||
.contains("字段签名未知或混合");
|
||||
}
|
||||
|
||||
private static int count(String value, String token) {
|
||||
return (value.length() - value.replace(token, "").length()) / token.length();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user