fix(lastleg): align overseas business incremental schema

This commit is contained in:
2026-08-25 13:07:01 +08:00
parent 995c1833f8
commit 79eb3efe61
4 changed files with 100 additions and 4 deletions
@@ -2,6 +2,8 @@ package com.baiyue.lastleg.looseboard;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.charset.StandardCharsets;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -24,4 +26,13 @@ class LocalLooseboardSchemaContractTest {
assertTrue(sql.contains("customer_id VARCHAR(128) NOT NULL COMMENT '客户数据隔离键'"));
assertTrue(sql.contains("idx_ll_loading_history_customer_order(customer_id,order_id,created_at)"));
}
@Test
void unifiedIncrementalContainsHistoryIdempotencyAndOperationLedger() throws Exception {
String sql = Files.readString(Path.of("..", "deploy", "sql", "海外区域统一增量-MySQL8.sql"),
StandardCharsets.UTF_8);
assertTrue(sql.contains("CREATE TABLE IF NOT EXISTS ll_local_looseboard_operation"));
assertTrue(sql.contains("uk_ll_local_looseboard_operation_key(customer_id,order_id,idempotency_key)"));
assertTrue(sql.contains("table_name='ll_local_looseboard_history' AND column_name='idempotency_key'"));
}
}
@@ -2,6 +2,8 @@ package com.baiyue.lastleg.procurement;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.charset.StandardCharsets;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -23,4 +25,21 @@ class OverseasProcurementSchemaContractTest {
org.junit.jupiter.api.Assertions.assertFalse(sql.contains("CREATE TABLE IF NOT EXISTS ll_overseas_procurement_outbound"));
org.junit.jupiter.api.Assertions.assertFalse(sql.contains("outbound_quantity BIGINT"));
}
@Test
void unifiedIncrementalContainsHistoryIdempotencyKeyForNewAndExistingDatabases() throws Exception {
String sql = Files.readString(
Path.of("..", "deploy", "sql", "海外区域统一增量-MySQL8.sql"),
StandardCharsets.UTF_8);
assertTrue(sql.contains("idempotency_key VARCHAR(255) NULL COMMENT '操作幂等键'"));
assertTrue(sql.contains(
"ALTER TABLE ll_overseas_procurement_status_history ADD COLUMN idempotency_key VARCHAR(255) NULL"));
assertTrue(sql.contains(
"ALTER TABLE ll_overseas_procurement_order ADD COLUMN review_idempotency_key VARCHAR(255) NULL"));
assertTrue(sql.contains(
"ALTER TABLE ll_overseas_procurement_order ADD COLUMN review_request_hash CHAR(64) NULL"));
assertTrue(sql.contains(
"table_name='ll_overseas_procurement_status_history' AND column_name='idempotency_key'"));
}
}
@@ -2,6 +2,8 @@ package com.baiyue.lastleg.trucking;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.charset.StandardCharsets;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -26,4 +28,14 @@ class UsTruckOrderSchemaContractTest {
assertTrue(sql.contains("UNIQUE KEY uk_ll_us_truck_order_key(customer_id,idempotency_key)"));
assertTrue(sql.contains("KEY idx_ll_us_truck_history(customer_id,order_id,created_at)"));
}
@Test
void unifiedIncrementalContainsOperationLedgerAndHistoryColumns() throws Exception {
String sql = Files.readString(Path.of("..", "deploy", "sql", "海外区域统一增量-MySQL8.sql"),
StandardCharsets.UTF_8);
assertTrue(sql.contains("CREATE TABLE IF NOT EXISTS ll_us_truck_order_operation"));
assertTrue(sql.contains("uk_ll_us_truck_operation_key(customer_id,order_id,idempotency_key)"));
assertTrue(sql.contains("table_name='ll_us_truck_order_status_history' AND column_name='operation_type'"));
assertTrue(sql.contains("table_name='ll_us_truck_order_status_history' AND column_name='idempotency_key'"));
}
}