0

I'm trying to add hstore to my application. However i get an error telling me that hstore does not exists.

PG::UndefinedObject: ERROR:  type "hstore" does not exist
LINE 1: ALTER TABLE "people" ADD COLUMN "custom_fields" hstore

This is my migration:

class AddCustomFieldsToPeople < ActiveRecord::Migration
  def up
    add_column :people, :custom_fields, :hstore
  end

  def down
    remove_column :people, :custom_fields
  end
end

Acording to this SO answer i do not have to create the hstore extention on every schema but only add it to for example the public schema.

Is there anything i need to do other that adding the postgres extension to get hstore to work?

Any help is appreciated. :)

Community
  • 1
  • 1
Ole Henrik Skogstrøm
  • 6,353
  • 10
  • 57
  • 89

1 Answers1

1

Generate a migration with this and rake:

class AddHstore < ActiveRecord::Migration  
  def up
    enable_extension :hstore
  end

  def down
    disable_extension :hstore
  end
end    

Since you will have a migration pending already, use rake db:migrate:up VERSION=

Arunkumar L
  • 11
  • 1
  • 2