fix: support deployed outbound detail schema

This commit is contained in:
zgw
2026-09-04 12:07:03 +08:00
parent b940bf0eb1
commit cab1151fef
3 changed files with 33 additions and 4 deletions

View File

@@ -1065,7 +1065,7 @@ BEGIN
warehouse.project_no AS [@project_no],
outbound.product_id AS [@product_id], outbound.lot_no AS [@lot_no],
outbound.quantity AS [@quantity], outbound.assign_num AS [@assign_num],
outbound.allot_quantity AS [@allot_quantity], outbound.create_time AS [@create_time]
outbound.allot_quantity AS [@allot_quantity]
FROM dbo.out_stockout_detail outbound WITH (NOLOCK)
JOIN dbo.out_stockout stockout WITH (NOLOCK) ON stockout.stockout_id = outbound.stockout_id
LEFT JOIN dbo.bas_warehouse warehouse WITH (NOLOCK)
@@ -1279,7 +1279,7 @@ BEGIN
warehouse.project_no AS [@project_no],
outbound.product_id AS [@product_id], outbound.lot_no AS [@lot_no],
outbound.quantity AS [@quantity], outbound.assign_num AS [@assign_num],
outbound.allot_quantity AS [@allot_quantity], outbound.create_time AS [@create_time]
outbound.allot_quantity AS [@allot_quantity]
FROM dbo.out_stockout_detail outbound WITH (NOLOCK)
JOIN dbo.out_stockout stockout WITH (NOLOCK) ON stockout.stockout_id = outbound.stockout_id
LEFT JOIN dbo.bas_warehouse warehouse WITH (NOLOCK)

View File

@@ -402,7 +402,7 @@ BEGIN
warehouse.project_no AS [@project_no],
outbound.product_id AS [@product_id], outbound.lot_no AS [@lot_no],
outbound.quantity AS [@quantity], outbound.assign_num AS [@assign_num],
outbound.allot_quantity AS [@allot_quantity], outbound.create_time AS [@create_time]
outbound.allot_quantity AS [@allot_quantity]
FROM dbo.out_stockout_detail outbound WITH (NOLOCK)
JOIN dbo.out_stockout stockout WITH (NOLOCK) ON stockout.stockout_id = outbound.stockout_id
LEFT JOIN dbo.bas_warehouse warehouse WITH (NOLOCK)
@@ -613,7 +613,7 @@ BEGIN
stockout.warehouse_id AS [@source_warehouse_id],
warehouse.project_no AS [@project_no],
outbound.product_id AS [@product_id], outbound.lot_no AS [@lot_no], outbound.quantity AS [@quantity],
outbound.assign_num AS [@assign_num], outbound.allot_quantity AS [@allot_quantity], outbound.create_time AS [@create_time]
outbound.assign_num AS [@assign_num], outbound.allot_quantity AS [@allot_quantity]
FROM dbo.out_stockout_detail outbound WITH (NOLOCK)
JOIN dbo.out_stockout stockout WITH (NOLOCK) ON stockout.stockout_id = outbound.stockout_id
LEFT JOIN dbo.bas_warehouse warehouse WITH (NOLOCK)

View File

@@ -64,6 +64,16 @@ class ShadowSqlServerMigrationScriptTest {
"procedure alg.usp_rebuild_lane_state",
"procedure alg.usp_refresh_dirty_lanes");
private static final Set<String> PRODUCTION_OUTBOUND_DETAIL_COLUMNS = Set.of(
"stockout_detail_id",
"stockout_id",
"warehouse_id",
"product_id",
"lot_no",
"quantity",
"assign_num",
"allot_quantity");
@Test
void installCreatesOnlyAllowListedShadowObjects() throws IOException {
String install = resource("db/sqlserver/install-shadow.sql");
@@ -246,6 +256,25 @@ class ShadowSqlServerMigrationScriptTest {
}
}
@Test
void refreshSupportsProductionOutboundDetailWithoutCreateTime() throws IOException {
for (String script : new String[]{"db/sqlserver/install-shadow.sql",
"db/sqlserver/upgrade-shadow-v2-to-v3.sql"}) {
String refresh = normalize(resource(script));
refresh = batchBody(refresh, "create procedure alg.usp_refresh_shadow_snapshot");
Set<String> referencedColumns = Pattern.compile("\\boutbound\\.([a-z0-9_]+)")
.matcher(refresh)
.results()
.map(match -> match.group(1))
.collect(java.util.stream.Collectors.toSet());
assertThat(referencedColumns)
.as("%s must support the deployed out_stockout_detail schema", script)
.isSubsetOf(PRODUCTION_OUTBOUND_DETAIL_COLUMNS);
}
}
@Test
void decisionReasonStoresBoundedUnicodeDiagnosticsAcrossCleanInstallAndUpgrade() throws IOException {
String install = normalize(resource("db/sqlserver/install-shadow.sql"));