Skip to content

Commit cc0653c

Browse files
authored
Fix: v0064 migration script dropping non-model snapshots (#3728)
1 parent 717d803 commit cc0653c

1 file changed

Lines changed: 16 additions & 17 deletions

File tree

sqlmesh/migrations/v0064_join_when_matched_strings.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,23 @@ def migrate(state_sync, **kwargs): # type: ignore
4545
parsed_snapshot = json.loads(snapshot)
4646
node = parsed_snapshot["node"]
4747

48-
if "kind" in node:
49-
kind = node["kind"]
50-
if isinstance(when_matched := kind.get("when_matched"), list):
51-
kind["when_matched"] = " ".join(when_matched)
48+
kind = node.get("kind")
49+
if kind and isinstance(when_matched := kind.get("when_matched"), list):
50+
kind["when_matched"] = " ".join(when_matched)
5251

53-
new_snapshots.append(
54-
{
55-
"name": name,
56-
"identifier": identifier,
57-
"version": version,
58-
"snapshot": json.dumps(parsed_snapshot),
59-
"kind_name": kind_name,
60-
"updated_ts": updated_ts,
61-
"unpaused_ts": unpaused_ts,
62-
"ttl_ms": ttl_ms,
63-
"unrestorable": unrestorable,
64-
}
65-
)
52+
new_snapshots.append(
53+
{
54+
"name": name,
55+
"identifier": identifier,
56+
"version": version,
57+
"snapshot": json.dumps(parsed_snapshot),
58+
"kind_name": kind_name,
59+
"updated_ts": updated_ts,
60+
"unpaused_ts": unpaused_ts,
61+
"ttl_ms": ttl_ms,
62+
"unrestorable": unrestorable,
63+
}
64+
)
6665

6766
if new_snapshots:
6867
engine_adapter.delete_from(snapshots_table, "TRUE")

0 commit comments

Comments
 (0)