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 a314f64ca9
commit ac31573db5
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
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
-- 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
UPDATE documents
SET ocr_status = 'pending',
@ -12,6 +15,9 @@ WHERE ocr_confidence = 85.0
AND ocr_status = 'completed'
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
COMMENT ON COLUMN documents.ocr_confidence IS 'OCR confidence percentage (0-100) from Tesseract. Documents with NULL confidence and pending status will be reprocessed.';