diff --git a/fortucky-algorithm/src/main/resources/db/sqlserver/install-shadow.sql b/fortucky-algorithm/src/main/resources/db/sqlserver/install-shadow.sql index 134e971..11843d6 100644 --- a/fortucky-algorithm/src/main/resources/db/sqlserver/install-shadow.sql +++ b/fortucky-algorithm/src/main/resources/db/sqlserver/install-shadow.sql @@ -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, diff --git a/fortucky-algorithm/src/test/java/com/ruoyi/algorithm/repository/ShadowSqlServerMigrationScriptTest.java b/fortucky-algorithm/src/test/java/com/ruoyi/algorithm/repository/ShadowSqlServerMigrationScriptTest.java index 7cea744..5121dce 100644 --- a/fortucky-algorithm/src/test/java/com/ruoyi/algorithm/repository/ShadowSqlServerMigrationScriptTest.java +++ b/fortucky-algorithm/src/test/java/com/ruoyi/algorithm/repository/ShadowSqlServerMigrationScriptTest.java @@ -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"));