fix(catalog): 快照节点绑定物化条目以显示导入进度

This commit is contained in:
姚章浩
2026-09-15 16:50:15 +08:00
parent 40d0c511d6
commit 0ef41594c2
8 changed files with 208 additions and 16 deletions
@@ -0,0 +1,10 @@
-- Undo the backfill: nodes bound to policy-materialized (cat:) items.
UPDATE source_catalog_nodes node
SET source_item_id = NULL
FROM source_items item, catalog_import_intents intent, source_catalog_snapshots snap
WHERE item.id = node.source_item_id
AND item.stable_external_id LIKE 'cat:%'
AND snap.source_connection_id = intent.source_connection_id
AND node.snapshot_id = snap.id
AND node.node_id = intent.node_id
AND intent.source_item_id = item.id;
@@ -0,0 +1,15 @@
-- Bind snapshot file nodes to the source items their policy intents created.
-- Before this migration, annotation materialized items and linked them only on
-- catalog_import_intents; the catalog browser's 已导入/已解析 counters join
-- source_catalog_nodes.source_item_id, so every catalog-only source (ATOM and
-- friends) kept showing 尚未导入 even after documents finished parsing.
-- node_id is deterministic per (connection, path), so intents map 1:1.
UPDATE source_catalog_nodes node
SET source_item_id = intent.source_item_id
FROM catalog_import_intents intent, source_catalog_snapshots snap
WHERE snap.source_connection_id = intent.source_connection_id
AND node.snapshot_id = snap.id
AND node.node_id = intent.node_id
AND node.node_type = 'file'
AND node.source_item_id IS NULL
AND intent.source_item_id IS NOT NULL;