Во время миграции я получаю erorr dmetaphone не существует, и я проверяю, есть ли уже расширение fuzzystrmatch, что может быть причиной этой ошибки?
class AddPgSearchDmetaphoneSupportFunctions < ActiveRecord::Migration
def self.up
say_with_time("Adding support functions for pg_search :dmetaphone") do
execute <<-'SQL'
CREATE OR REPLACE FUNCTION pg_search_dmetaphone n(text) RETURNS text LANGUAGE SQL IMMUTABLE STRICT AS $function$
SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(regexp_split_to_array($1, E'\\s+')))), ' ')
$function$;
SQL
end
end
def self.down
say_with_time("Dropping support functions for pg_search :dmetaphone") do
execute <<-'SQL'
DROP FUNCTION pg_search_dmetaphone(text);
SQL
end
end
end
Вот журнал ошибок.
== 20170324124420 AddPgSearchDmetaphoneSupportFunctions: migrating ============
-- Adding support functions for pg_search :dmetaphone
-- execute("CREATE OR REPLACE FUNCTION pg_search_dmetaphone(text) RETURNS text LANGUAGE SQL IMMUTABLE STRICT AS $function$\n SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(regexp_split_to_array($1, E'\\\\s+')))), ' ')\n$function$;\n")
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedFunction: ERROR: function dmetaphone(text) does not exist
LINE 2: SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(rege...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
: CREATE OR REPLACE FUNCTION pg_search_dmetaphone(text) RETURNS text LANGUAGE SQL IMMUTABLE STRICT AS $function$
SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(regexp_split_to_array($1, E'\\s+')))), ' ')
Вот журналы psql для fuzzystrmatch.
db_dev=# create extension fuzzystrmatch;
ERROR: function "levenshtein" already exists with same argument types