Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-3100 [FIX] Remove TrigramExtension and GIN index to fix on-premise installation failures (#1706)

alia70a17850565
diff --git a/backend/workflow_manager/workflow_v2/file_history_views.py b/backend/workflow_manager/workflow_v2/file_history_views.py
index 316cec593..6a1562194 100644
--- a/backend/workflow_manager/workflow_v2/file_history_views.py
+++ b/backend/workflow_manager/workflow_v2/file_history_views.py
@@ -77,8 +77,8 @@ class FileHistoryViewSet(viewsets.ReadOnlyModelViewSet):
file_path_param = self.request.query_params.get("file_path")
if file_path_param:
- # Support partial matching (case-insensitive)
- queryset = queryset.filter(file_path__icontains=file_path_param)
+ # Support prefix matching (case-insensitive) - uses B-tree index efficiently
+ queryset = queryset.filter(file_path__istartswith=file_path_param)
return queryset.order_by("-created_at")
@@ -162,7 +162,7 @@ class FileHistoryViewSet(viewsets.ReadOnlyModelViewSet):
queryset = queryset.filter(execution_count__lte=exec_max_val)
if file_path_param:
- queryset = queryset.filter(file_path__icontains=file_path_param)
+ queryset = queryset.filter(file_path__istartswith=file_path_param)
deleted_count, _ = queryset.delete()
diff --git a/backend/workflow_manager/workflow_v2/migrations/0018_filehistory_execution_count_and_more.py b/backend/workflow_manager/workflow_v2/migrations/0018_filehistory_execution_count_and_more.py
index 1e02961d7..5237ad1df 100644
--- a/backend/workflow_manager/workflow_v2/migrations/0018_filehistory_execution_count_and_more.py
+++ b/backend/workflow_manager/workflow_v2/migrations/0018_filehistory_execution_count_and_more.py
@@ -1,8 +1,6 @@
# Generated by Django 4.2.1 on 2025-11-24 12:41
import django.core.validators
-from django.contrib.postgres.indexes import GinIndex
-from django.contrib.postgres.operations import TrigramExtension
from django.db import migrations, models
@@ -12,8 +10,10 @@ class Migration(migrations.Migration):
]
operations = [
- # Enable PostgreSQL trigram extension for fast partial text matching
- TrigramExtension(),
+ # NOTE: TrigramExtension and GIN trigram index removed - not needed
+ # for complete filepath search and causes issues on some PostgreSQL setups
+ # that don't have pg_trgm extension or lack superuser privileges.
+ # See migration 0019 for cleanup of existing installations.
migrations.AddField(
model_name="filehistory",
name="execution_count",
@@ -47,13 +47,4 @@ class Migration(migrations.Migration):
fields=["workflow", "file_path"], name="idx_fh_workflow_filepath"
),
),
- # Add GIN trigram index for fast partial file_path search (10-250x faster)
- migrations.AddIndex(
- model_name="filehistory",
- index=GinIndex(
- fields=["file_path"],
- name="idx_fh_file_path_trgm",
- opclasses=["gin_trgm_ops"],
- ),
- ),
]
diff --git a/backend/workflow_manager/workflow_v2/migrations/0019_remove_filehistory_trigram_index.py b/backend/workflow_manager/workflow_v2/migrations/0019_remove_filehistory_trigram_index.py
new file mode 100644
index 000000000..b4879f701
--- /dev/null
+++ b/backend/workflow_manager/workflow_v2/migrations/0019_remove_filehistory_trigram_index.py
@@ -0,0 +1,30 @@
+# Generated by Django 4.2.1 on 2025-12-17
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+ """Remove the trigram GIN index from FileHistory.
+
+ This migration safely removes the pg_trgm GIN index that was added in 0018.
+ The trigram index is not needed as we only require complete filepath search,
+ not partial/fuzzy matching. Additionally, the TrigramExtension requires
+ superuser privileges which may not be available on all PostgreSQL installations.
+
+ This migration is safe to run on:
+ - Production: Will drop the existing GIN index
+ - New installations: Will be a no-op (index doesn't exist)
+ """
+
+ dependencies = [
+ ("workflow_v2", "0018_filehistory_execution_count_and_more"),
+ ]
+
+ operations = [
+ migrations.RunSQL(
+ # Forward: Drop the GIN index if it exists
+ sql="DROP INDEX IF EXISTS idx_fh_file_path_trgm;",
+ # Reverse: No-op - we don't want to recreate it
+ reverse_sql=migrations.RunSQL.noop,
+ ),
+ ]
diff --git a/backend/workflow_manager/workflow_v2/models/file_history.py b/backend/workflow_manager/workflow_v2/models/file_history.py
index ca0094e93..c45ec609d 100644
--- a/backend/workflow_manager/workflow_v2/models/file_history.py
+++ b/backend/workflow_manager/workflow_v2/models/file_history.py
@@ -1,6 +1,5 @@
import uuid
-from django.contrib.postgres.indexes import GinIndex
from django.db import models
from django.db.models import Q
from utils.models.base_model import BaseModel
@@ -94,11 +93,6 @@ class FileHistory(BaseModel):
models.Index(
fields=["workflow", "file_path"], name="idx_fh_workflow_filepath"
),
- GinIndex(
- fields=["file_path"],
- name="idx_fh_file_path_trgm",
- opclasses=["gin_trgm_ops"],
- ),
]
constraints = [
# Legacy behavior: file_path is not present or is null
diff --git a/frontend/src/components/pipelines-or-deployments/file-history-modal/FileHistoryModal.jsx b/frontend/src/components/pipelines-or-deployments/file-history-modal/FileHistoryModal.jsx
index e3684340d..1c8bd2f54 100644
--- a/frontend/src/components/pipelines-or-deployments/file-history-modal/FileHistoryModal.jsx
+++ b/frontend/src/components/pipelines-or-deployments/file-history-modal/FileHistoryModal.jsx
@@ -537,7 +537,7 @@ const FileHistoryModal = ({ open, setOpen, workflowId, workflowName }) => {
File Path:
</Text>
<Input
- placeholder="Search by file path..."
+ placeholder="File path starts with..."
value={filePathFilter}
onChange={(e) => setFilePathFilter(e.target.value)}
allowClear