pg_search 安装 contrib 包后 dmetaphone 不工作

pg_search dmetaphone not working after installing contrib package

安装 pq_search 和 运行 contrib 包迁移后:

class InstallSomeContribPackages < ActiveRecord::Migration
  def up
    execute 'CREATE EXTENSION pg_trgm;'
    execute 'CREATE EXTENSION fuzzystrmatch;'
  end

  def down
    execute 'DROP EXTENSION pg_trgm;'
    execute 'DROP EXTENSION fuzzystrmatch;'
  end
end

迁移dmetaphone迁移时仍然抛出错误:

PG::UndefinedFunction: ERROR:  function dmetaphone(text) does not exist
LINE 2:   SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(rege...

我向遇到此问题的其他人发布了这个问题...

即使有了 contrib 包,我仍然需要安装 fuzzystrmatch 扩展。

尝试耙 db:setup 和耙 db:test:prepare

如果这不起作用,则对每个环境执行以下操作:

在终端本地访问您的 psql 并创建扩展:

\psql
create extension fuzzystrmatch;

在 heroku 上访问您的 psql 数据库并从终端创建扩展:

heroku pg:psql
create extension fuzzystrmatch;

然后重新运行迁移。希望这有助于减轻其他人的压力。