Skip to content

Commit 721e310

Browse files
authored
Fix: Make sure that seed column hashes are updated during the migration (#863)
1 parent 4d8cbca commit 721e310

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

sqlmesh/core/model/definition.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,9 @@ def to_hydrated(self, content: str) -> SeedModel:
790790
"""
791791
if self.is_hydrated:
792792
return self
793-
return self.copy(update={"seed": Seed(content=content), "is_hydrated": True})
793+
return self.copy(
794+
update={"seed": Seed(content=content), "is_hydrated": True, "column_hashes_": None}
795+
)
794796

795797
def is_breaking_change(self, previous: Model) -> t.Optional[bool]:
796798
if not isinstance(previous, SeedModel):

sqlmesh/core/state_sync/engine_adapter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def _backup_state(self) -> None:
445445
)
446446

447447
def _migrate_rows(self) -> None:
448-
all_snapshots = self._get_snapshots(lock_for_update=True)
448+
all_snapshots = self._get_snapshots(lock_for_update=True, hydrate_seeds=True)
449449
environments = self.get_environments()
450450

451451
snapshot_mapping = {}

tests/core/test_model.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ def test_seed_hydration():
368368
assert hydrated_model.is_hydrated
369369
assert hydrated_model.column_hashes == column_hashes
370370
assert hydrated_model.seed.content == model.seed.content
371+
assert hydrated_model.column_hashes_ is None
371372

372373

373374
def test_seed():

0 commit comments

Comments
 (0)