c10fa98d0a
Restore original migrations (001-120) to fix schema_migrations version mismatch * Restore original migrations (001-120) to fix schema_migrations version mismatch The previous migration collapse broke deployed databases because: - Dev database was at version 120 (the real remove_text_extraction migration) - Main had collapsed migrations (001-012) + stub files (119_stub, 120_stub) - The migrate tool couldn't find version 119/120 with matching content This commit restores the original 27 migrations (versions 001-120) from before the collapse, ensuring backward compatibility with existing databases.
33 lines
1.4 KiB
SQL
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;
|