… dev plans (
SQLMesh#5719)
Extend _check_destructive_additive_changes in PlanBuilder to also inspect
indirectly modified forward-only snapshots for destructive/additive schema
changes. Previously, only directly modified snapshots were checked, and the
evaluator-level check (MigrateSchemasStage) is skipped for dev plans.
Changes:
- Refactor schema diffing into reusable _check_schema_change helper
- Pass indirectly_modified mapping to _check_destructive_additive_changes
- Add loop to check indirectly modified forward-only snapshots
- Add 5 new tests for is_dev=True scenarios (ERROR/WARN/ALLOW modes,
indirect modification, --forward-only flag)
Summary
Fixes #5719. Destructive schema changes on forward-only models are now surfaced at plan-build time during dev plans (sqlmesh plan dev), not just prod plans.
Problem
When a forward-only model has columns removed or types narrowed, sqlmesh plan dev and PR checks would succeed, but the production deployment would fail with a DestructiveChangeError during MigrateSchemasStage. This left the production environment in an unfinalized state.
Root Cause
PlanBuilder._check_destructive_additive_changes already checked for destructive schema changes at plan-build time (regardless of is_dev), but only for directly modified snapshots. Indirectly modified forward-only models (e.g., downstream models inheriting schema changes from an upstream dependency) were not checked. The evaluator-level check in MigrateSchemasStage catches these for prod, but that stage is skipped for dev plans.
Changes
sqlmesh/core/plan/builder.py
tests/core/test_plan.py
Add 5 new tests for is_dev=True scenarios:
Test Results
All 27 forward-only/destructive tests pass (5 new + 22 existing), zero regressions.