-- =====================================================
-- Migration: Add GIN indexes for llm schema
-- Task: ST-4.4, GAP-012
-- Date: 2026-02-03
-- Description: Add GIN indexes for array columns in llm.conversations
--              for optimized full-text tag searches
-- =====================================================

-- GIN index on tags array for fast tag searches
CREATE INDEX IF NOT EXISTS idx_conversations_tags_gin
ON llm.conversations USING GIN(tags);

-- GIN index on related_symbols for symbol searches
CREATE INDEX IF NOT EXISTS idx_conversations_symbols_gin
ON llm.conversations USING GIN(related_symbols);

-- GIN index on related_topics for topic searches
CREATE INDEX IF NOT EXISTS idx_conversations_topics_gin
ON llm.conversations USING GIN(related_topics);

-- =====================================================
-- Verification
-- =====================================================
-- To verify indexes were created:
-- SELECT indexname FROM pg_indexes
-- WHERE tablename='conversations' AND schemaname='llm';
-- =====================================================
