@@ -65,11 +65,9 @@ class PlanBuilder:
6565 restate_models: A list of models for which the data should be restated for the time range
6666 specified in this plan. Note: models defined outside SQLMesh (external) won't be a part
6767 of the restatement.
68- clear_restated_intervals_across_model_versions : If restatements are present, this flag indicates whether or not the intervals
68+ restate_all_snapshots : If restatements are present, this flag indicates whether or not the intervals
6969 being restated should be cleared from state for other versions of this model (typically, versions that are present in other environments).
7070 If set to None, the default behaviour is to not clear anything unless the target environment is prod.
71- always_include_local_changes: Usually when restatements are present, local changes in the filesystem are ignored.
72- However, it can be desirable to deploy changes + restatements in the same plan, so this flag overrides the default behaviour.
7371 backfill_models: A list of fully qualified model names for which the data should be backfilled as part of this plan.
7472 no_gaps: Whether to ensure that new snapshots for nodes that are already a
7573 part of the target environment have no data gaps when compared against previous
@@ -108,8 +106,7 @@ def __init__(
108106 execution_time : t .Optional [TimeLike ] = None ,
109107 apply : t .Optional [t .Callable [[Plan ], None ]] = None ,
110108 restate_models : t .Optional [t .Iterable [str ]] = None ,
111- clear_restated_intervals_across_model_versions : bool = False ,
112- always_include_local_changes : t .Optional [bool ] = None ,
109+ restate_all_snapshots : bool = False ,
113110 backfill_models : t .Optional [t .Iterable [str ]] = None ,
114111 no_gaps : bool = False ,
115112 skip_backfill : bool = False ,
@@ -161,9 +158,7 @@ def __init__(
161158 self ._auto_categorization_enabled = auto_categorization_enabled
162159 self ._include_unmodified = include_unmodified
163160 self ._restate_models = set (restate_models ) if restate_models is not None else None
164- self ._clear_restated_intervals_across_model_versions = (
165- clear_restated_intervals_across_model_versions
166- )
161+ self ._restate_all_snapshots = restate_all_snapshots
167162 self ._effective_from = effective_from
168163
169164 # note: this deliberately doesnt default to now() here.
@@ -182,7 +177,6 @@ def __init__(
182177 self ._user_provided_flags = user_provided_flags
183178 self ._selected_models = selected_models
184179 self ._explain = explain
185- self ._always_include_local_changes = always_include_local_changes
186180
187181 self ._start = start
188182 if not self ._start and (
@@ -288,7 +282,6 @@ def build(self) -> Plan:
288282 if self ._latest_plan :
289283 return self ._latest_plan
290284
291- self ._ensure_no_new_snapshots_with_restatements ()
292285 self ._ensure_new_env_with_changes ()
293286 self ._ensure_valid_date_range ()
294287 self ._ensure_no_broken_references ()
@@ -351,7 +344,7 @@ def build(self) -> Plan:
351344 deployability_index = deployability_index ,
352345 selected_models_to_restate = self ._restate_models ,
353346 restatements = restatements ,
354- clear_restated_intervals_across_model_versions = self ._clear_restated_intervals_across_model_versions ,
347+ restate_all_snapshots = self ._restate_all_snapshots ,
355348 start_override_per_model = self ._start_override_per_model ,
356349 end_override_per_model = end_override_per_model ,
357350 selected_models_to_backfill = self ._backfill_models ,
@@ -871,21 +864,6 @@ def _ensure_no_broken_references(self) -> None:
871864 f"""Removed { broken_references_msg } are referenced in '{ snapshot .name } '. Please remove broken references before proceeding."""
872865 )
873866
874- def _ensure_no_new_snapshots_with_restatements (self ) -> None :
875- if self ._always_include_local_changes :
876- # the sqlmesh_dbt cli sets "always include local changes" to deliberately allow changes and restatements
877- # to be deployed in the same plan. If this is set, "force_no_diff" is also turned off on the ContextDiff
878- # so that the user is shown the local changes that will be applied and must accept them in order to run the plan
879- return
880-
881- if self ._restate_models is not None and (
882- self ._context_diff .new_snapshots or self ._context_diff .modified_snapshots
883- ):
884- raise PlanError (
885- "Model changes and restatements can't be a part of the same plan. "
886- "Revert or apply changes before proceeding with restatements."
887- )
888-
889867 def _ensure_new_env_with_changes (self ) -> None :
890868 if (
891869 self ._is_dev
0 commit comments