Babbz77
Babbz77

Reputation: 321

pg_search dmetaphone not working after installing contrib package

After installing pq_search and running contrib package migration:

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

It still throws error when migrating the dmetaphone migration:

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

Upvotes: 3

Views: 1258

Answers (1)

Babbz77
Babbz77

Reputation: 321

I posted this question for anyone else that struggled with this...

Even with the contrib package I still needed to install the fuzzystrmatch extension.

Try rake db:setup and rake db:test:prepare

If that doesn't work then do the following for each environment:

Locally access you psql in terminal and create extension:

\psql
create extension fuzzystrmatch;

On heroku access your psql db and create extension from terminal:

heroku pg:psql
create extension fuzzystrmatch;

Then rerun migration. Hope this helps save someone else stress.

Upvotes: 6

Related Questions