From 06f94a481161deec8bc9c1cd0bdb73ad9ad6c24e Mon Sep 17 00:00:00 2001 From: wizardchen Date: Wed, 27 May 2026 15:43:53 +0800 Subject: [PATCH] feat(migrations): add knowledge_processing_spans table for tracking document parsing progress - Introduced a new migration (000054) to create the knowledge_processing_spans table, which captures detailed progress of document parsing stages. - The table includes fields for span hierarchy, status tracking, and metadata to enhance visibility into the parsing pipeline. - Added indexes to optimize queries related to knowledge_id, attempt, and span relationships. - Implemented rollback migration to safely drop the table and associated indexes if needed. --- ....down.sql => 000054_knowledge_processing_spans.down.sql} | 6 +++--- ...pans.up.sql => 000054_knowledge_processing_spans.up.sql} | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename migrations/versioned/{000052_knowledge_processing_spans.down.sql => 000054_knowledge_processing_spans.down.sql} (56%) rename migrations/versioned/{000052_knowledge_processing_spans.up.sql => 000054_knowledge_processing_spans.up.sql} (95%) diff --git a/migrations/versioned/000052_knowledge_processing_spans.down.sql b/migrations/versioned/000054_knowledge_processing_spans.down.sql similarity index 56% rename from migrations/versioned/000052_knowledge_processing_spans.down.sql rename to migrations/versioned/000054_knowledge_processing_spans.down.sql index 9163ddbc..2c1f0974 100644 --- a/migrations/versioned/000052_knowledge_processing_spans.down.sql +++ b/migrations/versioned/000054_knowledge_processing_spans.down.sql @@ -1,9 +1,9 @@ --- Migration: 000052_knowledge_processing_spans (rollback) -DO $$ BEGIN RAISE NOTICE '[Migration 000052 rollback] Dropping table: knowledge_processing_spans'; END $$; +-- Migration: 000054_knowledge_processing_spans (rollback) +DO $$ BEGIN RAISE NOTICE '[Migration 000054 rollback] Dropping table: knowledge_processing_spans'; END $$; DROP INDEX IF EXISTS idx_kpspan_parent; DROP INDEX IF EXISTS idx_kpspan_status_started; DROP INDEX IF EXISTS idx_kpspan_knowledge_attempt; DROP TABLE IF EXISTS knowledge_processing_spans; -DO $$ BEGIN RAISE NOTICE '[Migration 000052 rollback] complete'; END $$; +DO $$ BEGIN RAISE NOTICE '[Migration 000054 rollback] complete'; END $$; diff --git a/migrations/versioned/000052_knowledge_processing_spans.up.sql b/migrations/versioned/000054_knowledge_processing_spans.up.sql similarity index 95% rename from migrations/versioned/000052_knowledge_processing_spans.up.sql rename to migrations/versioned/000054_knowledge_processing_spans.up.sql index 532b715b..14c273c4 100644 --- a/migrations/versioned/000052_knowledge_processing_spans.up.sql +++ b/migrations/versioned/000054_knowledge_processing_spans.up.sql @@ -1,4 +1,4 @@ --- Migration: 000052_knowledge_processing_spans +-- Migration: 000054_knowledge_processing_spans -- Per-(knowledge, attempt) span tree for the document parsing pipeline, -- inspired by Langfuse's trace / span / generation hierarchy. -- @@ -29,7 +29,7 @@ -- * SUBSPANs (multimodal.image[i], embedding.batch[i], postprocess.spawn.X) -- hang off their stage. The kind="generation" subset corresponds 1:1 to -- a Langfuse generation; metadata.langfuse_trace_id stitches them. -DO $$ BEGIN RAISE NOTICE '[Migration 000052] Creating table: knowledge_processing_spans'; END $$; +DO $$ BEGIN RAISE NOTICE '[Migration 000054] Creating table: knowledge_processing_spans'; END $$; CREATE TABLE IF NOT EXISTS knowledge_processing_spans ( id BIGSERIAL PRIMARY KEY, @@ -72,4 +72,4 @@ CREATE INDEX IF NOT EXISTS idx_kpspan_parent ON knowledge_processing_spans (parent_span_id) WHERE parent_span_id IS NOT NULL; -DO $$ BEGIN RAISE NOTICE '[Migration 000052] knowledge_processing_spans table ready'; END $$; +DO $$ BEGIN RAISE NOTICE '[Migration 000054] knowledge_processing_spans table ready'; END $$;