fix: initialize shadow snapshot state

This commit is contained in:
zgw
2026-09-03 13:52:52 +08:00
parent 3e9f61487c
commit 749bd49c50
2 changed files with 16 additions and 2 deletions

View File

@@ -1,8 +1,8 @@
/*
FT546 shadow-only read model for SQL Server 2016 RTM (13.0).
This package writes only alg.* and never changes Legacy WMS business rows.
A clean install creates an empty INITIALIZING package. The v3 worker owns
the first refresh and publication.
A clean install creates an INITIALIZING state for warehouse 01. The v3
worker owns the first refresh and publication.
*/
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
@@ -186,6 +186,10 @@ CREATE TABLE alg.shadow_snapshot_state (
);
GO
INSERT INTO alg.shadow_snapshot_state (warehouse_id, snapshot_generation, snapshot_status)
VALUES ('01', 0, 'INITIALIZING');
GO
CREATE TABLE alg.cargo_space_snapshot (
warehouse_id varchar(80) NOT NULL,
space_id varchar(80) NOT NULL,

View File

@@ -234,6 +234,16 @@ class ShadowSqlServerMigrationScriptTest {
"truncate table alg.decision_log");
}
@Test
void cleanInstallSeedsAuthoritativeWarehouseAsInitializing() throws IOException {
String install = normalize(resource("db/sqlserver/install-shadow.sql"));
assertThat(install).contains(
"insert into alg.shadow_snapshot_state "
+ "(warehouse_id, snapshot_generation, snapshot_status) "
+ "values ('01', 0, 'initializing')");
}
@Test
void claimUsesOnlyPackageHeartbeatAndA120SecondStaleThreshold() throws IOException {
String install = normalize(resource("db/sqlserver/install-shadow.sql"));