Skip to content

Commit

Permalink
Fix: v0064 migration script dropping non-model snapshots (#3728)
Browse files Browse the repository at this point in the history
  • Loading branch information
izeigerman authored Jan 27, 2025
1 parent 717d803 commit cc0653c
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions sqlmesh/migrations/v0064_join_when_matched_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,23 @@ def migrate(state_sync, **kwargs): # type: ignore
parsed_snapshot = json.loads(snapshot)
node = parsed_snapshot["node"]

if "kind" in node:
kind = node["kind"]
if isinstance(when_matched := kind.get("when_matched"), list):
kind["when_matched"] = " ".join(when_matched)
kind = node.get("kind")
if kind and isinstance(when_matched := kind.get("when_matched"), list):
kind["when_matched"] = " ".join(when_matched)

new_snapshots.append(
{
"name": name,
"identifier": identifier,
"version": version,
"snapshot": json.dumps(parsed_snapshot),
"kind_name": kind_name,
"updated_ts": updated_ts,
"unpaused_ts": unpaused_ts,
"ttl_ms": ttl_ms,
"unrestorable": unrestorable,
}
)
new_snapshots.append(
{
"name": name,
"identifier": identifier,
"version": version,
"snapshot": json.dumps(parsed_snapshot),
"kind_name": kind_name,
"updated_ts": updated_ts,
"unpaused_ts": unpaused_ts,
"ttl_ms": ttl_ms,
"unrestorable": unrestorable,
}
)

if new_snapshots:
engine_adapter.delete_from(snapshots_table, "TRUE")
Expand Down

0 comments on commit cc0653c

Please sign in to comment.