-
Notifications
You must be signed in to change notification settings - Fork 232
Installing Postgres Contrib Modules
Hey, the Readme says I need PostgreSQL contrib packages for certain features. How do I install those?
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