Cannot add hstore column to multitenant rails 4 applicaiton (postgres schema based)

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. :)

Upvotes: 0

Views: 337

Answers (1)

Arunkumar L
Arunkumar L

Reputation: 11

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=

Upvotes: 1

Related Questions