feat(migration): disable OCR consistency trigger for OCR confidence backfill

This commit is contained in:
perf3ct 2025-06-28 17:23:35 +00:00
parent 5aae560d7e
commit 9f3371e4f3
1 changed files with 6 additions and 0 deletions

View File

@ -2,6 +2,9 @@
-- Since OCR confidence was previously hardcoded to 85%, we need to reprocess -- Since OCR confidence was previously hardcoded to 85%, we need to reprocess
-- these documents to get accurate confidence scores -- these documents to get accurate confidence scores
-- Temporarily disable the OCR consistency trigger to allow this migration
ALTER TABLE documents DISABLE TRIGGER trigger_validate_ocr_consistency;
-- Mark documents with exactly 85% confidence as pending OCR reprocessing -- Mark documents with exactly 85% confidence as pending OCR reprocessing
UPDATE documents UPDATE documents
SET ocr_status = 'pending', SET ocr_status = 'pending',
@ -12,6 +15,9 @@ WHERE ocr_confidence = 85.0
AND ocr_status = 'completed' AND ocr_status = 'completed'
AND ocr_text IS NOT NULL; AND ocr_text IS NOT NULL;
-- Re-enable the OCR consistency trigger
ALTER TABLE documents ENABLE TRIGGER trigger_validate_ocr_consistency;
-- Add a comment explaining what we did -- Add a comment explaining what we did
COMMENT ON COLUMN documents.ocr_confidence IS 'OCR confidence percentage (0-100) from Tesseract. Documents with NULL confidence and pending status will be reprocessed.'; COMMENT ON COLUMN documents.ocr_confidence IS 'OCR confidence percentage (0-100) from Tesseract. Documents with NULL confidence and pending status will be reprocessed.';