-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you install the contrib packages? #38
Comments
I should really write a wiki page for this. Essentially the answer (for PostgreSQL 9.1 and up) is that you will need to run these SQL statements against the Rails database. Probably the easiest way to do this is to write a migration using the execute method. 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 If this fails, then you will need to install the contrib packages through whichever mechanism is best for your OS. In Mac OS X, I use Homebrew to install PostgreSQL, which compiles and installs all the contrib packages by default. Ubuntu appears to have a package called postgresql-contrib. Note that the contrib packages need to be present on the server running the database, which might be different than the server running the application. Heroku supports a few contrib packages, but I don't know the details on how to set them up there. You will need to run them for each environment, and you will also want to change the schema format in your config/application.rb file (as explained in the migrations guide): config.active_record.schema_format = :sql |
Thank you! Do I need to add "config.active_record.schema_format = :sql", or is that only when the migration option fails? I read the migrations guide, and still had a difficult time understanding the true reasoning behind using :sql rather than :rb. I'm just afraid by changing it to :sql will cause some issues that I don't understand. I am pretty new to RoR, so please be understanding of my questions :) |
Update --> I created a migrations file like the one above and migrated, and also changed the schema format to :sql.
but I still get an error when I try searching
p.s. It worked when I only used tsearch. |
You need to make the schema_format change so that when you use Essentially the default way Rails stores the schema does not have any knowledge or insight into how PostgreSQL uses extensions. The raw SQL format contains everything you need to quickly set up new databases for development, production, and testing. |
The |
I see - so I have nothing to worry about in terms of (potentially) losing my production database out of ignorance? I looked at the available Heroku plugins, but wasn't too sure if Heroku would support the things I'm trying to use with PG_Search for free. It might be a good idea to specify whether Heroku supports it for free in the readme docs, as I'm assuming a lot of the ppl using gems don't really understand what's going on and just want to know how to do it and whether it's possible. |
Got it! Update: The comment below was how I solved my issue. Sorry for not updating with the solution right away. Thanks for the catch. |
For future visitors with the same problem as @zreitano, you need to install the |
Ran into this pg_search_dmetaphone problem, however the rails g migration command listed in the documentation was not working for me. If that happens to you, you can create a migration however you create them (I use rails g migration) then use the guts of the migration here: |
For some reason the contrib package migration is not working on heroku. Does someone have a solution for this? |
I'm having the same problems as everyone else. I performed a migration and schema.rb update but I still get
|
@nodox Does you schema have these at the top: enable_extension "plpgsql" I run into this problem every time I use pg_search and quite honestly I never know what fixes it. Possibly try to do: bundle exec rake db:schema:load Otherwise I've also solved it by doing this: |
@Babbz75 Thanks for the response. I got it working using the last comment on issue #175 These steps worked for me:
|
Here's our documentation for installing PostgreSQL extensions. |
I've looked everywhere, but I can't seem to find how to install the trigram and fuzzy contrib packages. I am currently using Ubuntu 11.10 and Postgres 9.1.3 (recently updated), but I can't figure out where exactly I am supposed to type 'CREATE EXTENSION' or 'gmake install.'
These are the comments I made while I was trying to figure it out, but I don't think it works still.
#1. go here http://www.cyberciti.biz/faq/linux-installing-postgresql-database-server/
#2. enter '$ su - postgres'
#3. password is either just enter, or you can define pword by 'sudo passwd postgres'
#4. '$ psql template1'
#5. 'CREATE EXTENSION pg_trgm'
#6. 'CREATE EXTENSION fuzzystrmatch'
cd /usr/share/postgresql/9.1/extension
The text was updated successfully, but these errors were encountered: