-- +goose Up CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE EXTENSION IF NOT EXISTS unaccent; CREATE OR REPLACE FUNCTION immutable_unaccent(regdictionary, TEXT) RETURNS TEXT LANGUAGE c IMMUTABLE PARALLEL SAFE STRICT AS '$libdir/unaccent', 'unaccent_dict'; CREATE OR REPLACE FUNCTION f_unaccent(TEXT) RETURNS TEXT immutable strict parallel safe language sql as $$ SELECT public.immutable_unaccent(regdictionary 'public.unaccent', $1) $$; CREATE INDEX IF NOT EXISTS players_unaccent_display_name_trgm_idx ON players USING gin (f_unaccent(display_name::text) gin_trgm_ops); CREATE INDEX IF NOT EXISTS teams_unaccent_display_name_trgm_idx ON teams USING gin (f_unaccent(display_name::text) gin_trgm_ops); -- +goose Down DROP INDEX IF EXISTS players_unaccent_display_name_trgm_idx; DROP INDEX IF EXISTS teams_unaccent_display_name_trgm_idx; DROP FUNCTION IF EXISTS f_unaccent; DROP FUNCTION IF EXISTS immutable_unaccent; DROP EXTENSION IF EXISTS unaccent; DROP EXTENSION IF EXISTS pg_trgm;