Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sqlmesh/core/snapshot/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ def expiration_ts(self) -> int:
@property
def supports_schema_migration_in_prod(self) -> bool:
"""Returns whether or not this snapshot supports schema migration when deployed to production."""
return self.is_paused and self.is_model and not self.is_symbolic
return self.is_paused and self.is_model and not self.is_symbolic and not self.is_seed

@property
def requires_schema_migration_in_prod(self) -> bool:
Expand Down
36 changes: 36 additions & 0 deletions tests/core/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,42 @@ def test_run_with_select_models(
}


@time_machine.travel("2023-01-08 15:00:00 UTC")
def test_seed_model_promote_to_prod_after_dev(
init_and_plan_context: t.Callable,
):
context, plan = init_and_plan_context("examples/sushi")
context.apply(plan)

with open(context.path / "seeds" / "waiter_names.csv", "a") as f:
f.write("\n10,New Waiter")

context.load()

waiter_names_snapshot = context.get_snapshot("sushi.waiter_names")
plan = context.plan("dev", skip_tests=True, auto_apply=True, no_prompts=True)
assert waiter_names_snapshot.snapshot_id in plan.directly_modified

# Trigger a metadata change to reuse the previous version
waiter_names_model = waiter_names_snapshot.model.copy(
update={"description": "Updated description"}
)
context.upsert_model(waiter_names_model)
context.plan("dev", skip_tests=True, auto_apply=True, no_prompts=True)

# Promote all changes to prod
waiter_names_snapshot = context.get_snapshot("sushi.waiter_names")
plan = context.plan_builder("prod", skip_tests=True).build()
# Clear the cache to source the dehydrated model instance from the state
context.clear_caches()
context.apply(plan)

assert (
context.engine_adapter.fetchone("SELECT COUNT(*) FROM sushi.waiter_names WHERE id = 10")[0]
== 1
)


@time_machine.travel("2023-01-08 15:00:00 UTC")
def test_plan_with_run(
init_and_plan_context: t.Callable,
Expand Down