@@ -83,6 +83,44 @@ def test_restatement_plan_ignores_changes(init_and_plan_context: t.Callable):
8383 context .apply (plan )
8484
8585
86+ @time_machine .travel ("2023-01-08 15:00:00 UTC" )
87+ def test_prod_restatement_with_unbackfilled_dev_version (init_and_plan_context : t .Callable ):
88+ """
89+ Scenario:
90+ Prod is built. A breaking change is planned to `dev` with `--skip-backfill`,
91+ so `dev` holds a different snapshot version with no interval rows. Prod is
92+ then restated.
93+ Outcome:
94+ RestatementStage tries to clear `dev` intervals for that other version, finds
95+ none in `_intervals`, and no-ops instead of crashing on an empty insert. Prod
96+ restatement still applies; the un-backfilled `dev` snapshot still has no
97+ intervals.
98+ """
99+ context , plan = init_and_plan_context ("examples/sushi" )
100+ context .apply (plan )
101+
102+ prod_snapshot_id = context .get_snapshot ("sushi.waiter_revenue_by_day" ).snapshot_id
103+
104+ context .upsert_model (
105+ add_projection_to_model (t .cast (SqlModel , context .get_model ("sushi.waiter_revenue_by_day" )))
106+ )
107+ context .plan ("dev" , skip_backfill = True , auto_apply = True , no_prompts = True )
108+
109+ dev_snapshot_id = context .get_snapshot ("sushi.waiter_revenue_by_day" ).snapshot_id
110+ assert dev_snapshot_id != prod_snapshot_id
111+ assert not context .state_sync .get_snapshots ([dev_snapshot_id ])[dev_snapshot_id ].intervals
112+
113+ context .plan (
114+ restate_models = ["sushi.waiter_revenue_by_day" ],
115+ start = "2023-01-07" ,
116+ end = "2023-01-08" ,
117+ auto_apply = True ,
118+ no_prompts = True ,
119+ )
120+
121+ assert not context .state_sync .get_snapshots ([dev_snapshot_id ])[dev_snapshot_id ].intervals
122+
123+
86124@time_machine .travel ("2023-01-08 15:00:00 UTC" )
87125def test_restatement_plan_across_environments_snapshot_with_shared_version (
88126 init_and_plan_context : t .Callable ,
0 commit comments