38980-vm/app-9w9pd00g5j41/supabase/migrations/00026_normalize_lead_interests_case.sql
2026-03-04 18:25:09 +00:00

13 lines
526 B
SQL

-- Normalize all existing lead interests to lowercase for consistent matching
-- This fixes the case sensitivity issue between lead interests and provider categories
-- Update all existing leads to have lowercase interests
UPDATE leads
SET interests = (
SELECT array_agg(lower(trim(interest)))
FROM unnest(interests) AS interest
)
WHERE interests IS NOT NULL;
-- Add a comment explaining the normalization
COMMENT ON COLUMN leads.interests IS 'Array of interest tags (stored in lowercase for case-insensitive matching)';