-- Migration: Add document_group_id and page_number for multi-page document grouping. -- A document_group_id groups multiple sessions that belong to the same scanned document. -- page_number is the 1-based page index within the group. ALTER TABLE ocr_pipeline_sessions ADD COLUMN IF NOT EXISTS document_group_id UUID, ADD COLUMN IF NOT EXISTS page_number INT; -- Index for efficient group lookups CREATE INDEX IF NOT EXISTS idx_ocr_sessions_document_group ON ocr_pipeline_sessions (document_group_id) WHERE document_group_id IS NOT NULL;