Skip to content

Commit 740bf71

Browse files
authored
Fix: Prefer existing snapshots when mapping snapshot records during migration (#1940)
1 parent 4405c72 commit 740bf71

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

sqlmesh/core/state_sync/engine_adapter.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,10 @@ def _migrate_rows(self) -> None:
925925

926926
new_snapshot_id = new_snapshot.snapshot_id
927927

928-
if (
928+
if new_snapshot_id in all_snapshots:
929+
# Mapped to an existing snapshot.
930+
new_snapshots[new_snapshot_id] = all_snapshots[new_snapshot_id]
931+
elif (
929932
new_snapshot_id not in new_snapshots
930933
or new_snapshot.updated_ts > new_snapshots[new_snapshot_id].updated_ts
931934
):
@@ -981,7 +984,10 @@ def map_data_versions(
981984
self._update_environment(environment)
982985

983986
if updated_prod_environment:
984-
self.unpause_snapshots(updated_prod_environment.snapshots, now_timestamp())
987+
try:
988+
self.unpause_snapshots(updated_prod_environment.snapshots, now_timestamp())
989+
except Exception:
990+
logger.warning("Failed to unpause migrated snapshots", exc_info=True)
985991

986992
def _snapshot_id_filter(
987993
self, snapshot_ids: t.Iterable[SnapshotIdLike], alias: t.Optional[str] = None

0 commit comments

Comments
 (0)