Skip to content

Commit e844a87

Browse files
committed
simplify
1 parent f023d8f commit e844a87

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

sqlmesh/core/plan/stages.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,7 @@ def build(self, plan: EvaluatablePlan) -> t.List[PlanStage]:
281281
snapshots_with_schema_migration = [
282282
snapshots[s_id]
283283
for s_id in dag.subdag(*snapshot_ids_with_schema_migration)
284-
if snapshots[s_id].is_paused
285-
and snapshots[s_id].is_model
286-
and not snapshots[s_id].is_symbolic
284+
if snapshots[s_id].supports_schema_migration_in_prod
287285
]
288286

289287
snapshots_to_intervals = self._missing_intervals(

sqlmesh/core/snapshot/definition.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,19 +1477,19 @@ def expiration_ts(self) -> int:
14771477
check_categorical_relative_expression=False,
14781478
)
14791479

1480+
@property
1481+
def supports_schema_migration_in_prod(self) -> bool:
1482+
"""Returns whether or not this snapshot supports schema migration when deployed to production."""
1483+
return self.is_paused and self.is_model and not self.is_symbolic
1484+
14801485
@property
14811486
def requires_schema_migration_in_prod(self) -> bool:
14821487
"""Returns whether or not this snapshot requires a schema migration when deployed to production."""
1483-
return (
1484-
self.is_paused
1485-
and self.is_model
1486-
and not self.is_symbolic
1487-
and (
1488-
(self.previous_version and self.previous_version.version == self.version)
1489-
or self.model.forward_only
1490-
or bool(self.model.physical_version)
1491-
or not self.virtual_environment_mode.is_full
1492-
)
1488+
return self.supports_schema_migration_in_prod and (
1489+
(self.previous_version and self.previous_version.version == self.version)
1490+
or self.model.forward_only
1491+
or bool(self.model.physical_version)
1492+
or not self.virtual_environment_mode.is_full
14931493
)
14941494

14951495
@property

0 commit comments

Comments
 (0)