@@ -2697,3 +2697,59 @@ def test_unaligned_start_model_with_forward_only_preview(make_snapshot):
26972697 assert set (plan .restatements ) == {new_snapshot_a .snapshot_id , snapshot_b .snapshot_id }
26982698 assert not plan .deployability_index .is_deployable (new_snapshot_a )
26992699 assert not plan .deployability_index .is_deployable (snapshot_b )
2700+
2701+
2702+ def test_restate_production_model_in_dev (make_snapshot , mocker : MockerFixture ):
2703+ snapshot = make_snapshot (
2704+ SqlModel (
2705+ name = "test_model_a" ,
2706+ dialect = "duckdb" ,
2707+ query = parse_one ("select 1, ds" ),
2708+ kind = dict (name = ModelKindName .INCREMENTAL_BY_TIME_RANGE , time_column = "ds" ),
2709+ )
2710+ )
2711+
2712+ prod_snapshot = make_snapshot (
2713+ SqlModel (
2714+ name = "test_model_b" ,
2715+ dialect = "duckdb" ,
2716+ query = parse_one ("select 2, ds" ),
2717+ kind = dict (name = ModelKindName .INCREMENTAL_BY_TIME_RANGE , time_column = "ds" ),
2718+ )
2719+ )
2720+ prod_snapshot .unpaused_ts = 1
2721+
2722+ context_diff = ContextDiff (
2723+ environment = "test_environment" ,
2724+ is_new_environment = False ,
2725+ is_unfinalized_environment = True ,
2726+ normalize_environment_name = True ,
2727+ create_from = "prod" ,
2728+ create_from_env_exists = True ,
2729+ added = set (),
2730+ removed_snapshots = {},
2731+ modified_snapshots = {},
2732+ snapshots = {snapshot .snapshot_id : snapshot , prod_snapshot .snapshot_id : prod_snapshot },
2733+ new_snapshots = {},
2734+ previous_plan_id = None ,
2735+ previously_promoted_snapshot_ids = set (),
2736+ previous_finalized_snapshots = None ,
2737+ )
2738+
2739+ mock_console = mocker .Mock ()
2740+
2741+ plan = PlanBuilder (
2742+ context_diff ,
2743+ DuckDBEngineAdapter .SCHEMA_DIFFER ,
2744+ is_dev = True ,
2745+ restate_models = {snapshot .name , prod_snapshot .name },
2746+ console = mock_console ,
2747+ ).build ()
2748+
2749+ assert len (plan .restatements ) == 1
2750+ assert prod_snapshot .snapshot_id not in plan .restatements
2751+
2752+ mock_console .log_warning .assert_called_once_with (
2753+ "Cannot restate model '\" test_model_b\" ' because the current version is used in production. "
2754+ "Run the restatement against the production environment instead to restate this model."
2755+ )
0 commit comments