Files
query-orchestration/internal/database/migrations_archive/00000000000120_remove_text_extraction.up.sql
Jay Brown 35d72fccbe Merged in feature/remove-mocks (pull request #202)
Feature/remove mocks

* remove mocks

* cleanup db migrations
2026-01-15 20:39:32 +00:00

33 lines
1.4 KiB
SQL

-- Migration to remove text extraction functionality from the database
-- This drops all text extraction related tables, views, and functions
-- NOTE: Field extractions are separate and NOT affected by this migration
-- First drop the view that depends on text extraction tables
DROP VIEW IF EXISTS currentTextEntries;
-- Drop fullActiveCollectors view that depends on currentCollectorMinTextVersions
DROP VIEW IF EXISTS fullActiveCollectors;
-- Drop the currentCollectorMinTextVersions view
DROP VIEW IF EXISTS currentCollectorMinTextVersions;
-- Drop the trigger and function for collectorMinTextVersions
DROP TRIGGER IF EXISTS removeMinTextVersionTrigger ON collectorMinTextVersions;
DROP FUNCTION IF EXISTS removeMinTextVersion;
-- Drop the collectorMinTextVersions table
DROP TABLE IF EXISTS collectorMinTextVersions;
-- Drop the text extraction tables (child first for FK constraints)
DROP TABLE IF EXISTS documentTextExtractionEntries;
DROP TABLE IF EXISTS documentTextExtractions;
-- Recreate fullActiveCollectors view WITHOUT minTextVersion
CREATE VIEW fullActiveCollectors AS
SELECT DISTINCT av.clientId,
ccv.minCleanVersion,
av.activeVersion, lv.latestVersion
FROM collectorCurrentActiveVersions as av
JOIN collectorLatestVersions as lv on lv.clientId = av.clientId
JOIN currentCollectorMinCleanVersions AS ccv ON av.clientId = ccv.clientId;