From 4245be118a5f97c2e2ebb541f84d130841bb4328 Mon Sep 17 00:00:00 2001 From: rramprakash Date: Thu, 16 Jul 2026 12:27:57 +0530 Subject: [PATCH] fix(migration): remap firecrawl rows in the down migration The down migration narrows the searchengine_type enum by casting the engine column to a new enum that no longer contains 'firecrawl'. Any row logged with 'firecrawl' would make that cast fail, so a rollback errors out once the engine has been used. Remap those rows to 'tavily' before the cast so the down migration is safe on real data. --- .../sql/20260716_120000_add_firecrawl_search_type.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/migrations/sql/20260716_120000_add_firecrawl_search_type.sql b/backend/migrations/sql/20260716_120000_add_firecrawl_search_type.sql index 6b95898e..48697c94 100644 --- a/backend/migrations/sql/20260716_120000_add_firecrawl_search_type.sql +++ b/backend/migrations/sql/20260716_120000_add_firecrawl_search_type.sql @@ -40,6 +40,12 @@ CREATE TYPE SEARCHENGINE_TYPE_NEW AS ENUM ( 'sploitus' ); +-- Remap any rows logged with the removed value so the narrowing cast below +-- cannot fail; 'firecrawl' is a content-rich search engine like 'tavily'. +UPDATE searchlogs + SET engine = 'tavily' + WHERE engine = 'firecrawl'; + -- Update the searchlogs table to use the reverted enum type ALTER TABLE searchlogs ALTER COLUMN engine TYPE SEARCHENGINE_TYPE_NEW USING engine::text::SEARCHENGINE_TYPE_NEW;