Skip to content

Commit 43cfbf1

Browse files
committed
fix(workflows-mcp): source_type default NULL, migration v7 clears stale heuristic values
1 parent 8bf5b31 commit 43cfbf1

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/workflows_mcp/engine/knowledge/schema.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
SELECT 1 FROM information_schema.columns
256256
WHERE table_name = 'knowledge_propositions' AND column_name = 'source_type'
257257
) THEN
258-
ALTER TABLE knowledge_propositions ADD COLUMN source_type VARCHAR(50) DEFAULT 'DOCUMENT';
258+
ALTER TABLE knowledge_propositions ADD COLUMN source_type VARCHAR(50) DEFAULT NULL;
259259
END IF;
260260
END $$;
261261
@@ -318,6 +318,24 @@
318318
END $$;
319319
""",
320320
),
321+
(
322+
7,
323+
"Clarify knowledge_propositions.source_type semantics: drop misleading default, null-out stale values",
324+
"""
325+
DO $$
326+
BEGIN
327+
-- Drop the misleading DEFAULT 'DOCUMENT' — source_type must be set explicitly by callers.
328+
-- NULL means "origin unknown" (rows inserted before this was tracked correctly).
329+
ALTER TABLE knowledge_propositions
330+
ALTER COLUMN source_type DROP DEFAULT;
331+
332+
-- Null out the old heuristic values (DOCUMENT/TOOL were derived from source/path
333+
-- presence, not from actual ingestion origin — they are semantically meaningless).
334+
UPDATE knowledge_propositions SET source_type = NULL
335+
WHERE source_type IN ('DOCUMENT', 'TOOL');
336+
END $$;
337+
""",
338+
),
321339
]
322340

323341
SCHEMA_VERSION = MIGRATIONS[-1][0] if MIGRATIONS else 0

0 commit comments

Comments
 (0)