""" Enable the PostgreSQL extensions the search fallback relies on. ``pg_trgm`` powers ``TrigramSimilarity`` (typo tolerant name matching) and the GIN trigram index below makes ``ILIKE '%term%'`` on skill names fast enough for the type-ahead endpoint. """ from django.contrib.postgres.operations import TrigramExtension, UnaccentExtension from django.db import migrations class Migration(migrations.Migration): dependencies = [("profiles", "0001_initial")] operations = [ TrigramExtension(), UnaccentExtension(), migrations.RunSQL( sql=( "CREATE INDEX IF NOT EXISTS profile_full_name_trgm " "ON profiles_profile USING gin (full_name gin_trgm_ops);" ), reverse_sql="DROP INDEX IF EXISTS profile_full_name_trgm;", ), migrations.RunSQL( sql=( "CREATE INDEX IF NOT EXISTS skill_name_trgm " "ON profiles_skill USING gin (name gin_trgm_ops);" ), reverse_sql="DROP INDEX IF EXISTS skill_name_trgm;", ), ]