Rename the trigger node type to debounce, migrating stored flows

The store rewrites `"type": "trigger"` to `debounce` in every published and
draft flow when it opens, bumps the version and commits once. No alias stays
behind, so `trigger` is now an unknown type.
This commit is contained in:
2026-10-15 09:34:40 +02:00
parent 4a776e52c4
commit cfb9e53d68
9 changed files with 98 additions and 35 deletions
+28
View File
@@ -131,3 +131,31 @@ def test_renaming_onto_an_existing_name_is_refused(store: FlowStore):
store.rename_flow("heating", "warmth")
assert store.list_flows() == ["heating", "warmth"]
def test_opening_the_store_renames_trigger_nodes_to_debounce(store: FlowStore):
"""The old name has no alias, so what is stored under it is rewritten once."""
store.write_flow(
FlowDef(
name="hall",
nodes=[NodeDef(id="hold", type="trigger"), NodeDef(id="lamp")],
)
)
store.write_draft(
FlowDef(name="hall", nodes=[NodeDef(id="hold", type="trigger")]),
base_version=1,
)
commits = commit_count(store)
reopened = FlowStore(store.root)
published = reopened.read_flow("hall")
draft = reopened.read_flow("hall", draft=True)
assert [node.type for node in published.nodes] == ["debounce", "python"]
assert [node.type for node in draft.nodes] == ["debounce"]
# Bumped, so an editor holding the old draft cannot save `trigger` back.
assert (published.version, draft.version) == (2, 3)
assert commit_count(store) == commits + 1
FlowStore(store.root)
assert commit_count(store) == commits + 1