title: Rails 3.1, Postgres 9.1.4, hstore unknown operator error
body: <p>I'm trying to add an hstore data column to an existing STI model.</p>
  
  <p>Similar to <a href="https://stackoverflow.com/questions/11962436/postgres-hstore-errors-unknown-operator">Postgres HStore Errors - Unknown Operator</a> but as far as I can tell, I HAVE installed the hstore extension. I've dropped the database and rebuilt it from migrations without error but the specs still fail.  </p>
  
  <pre><code>Mac OS X 10.8.2
  Rails 3.1.10
  psql (PostgreSQL) 9.1.4
  </code></pre>
  
  <p>user.rb</p>
  
  <pre><code>has_many :targets
  
  def complete_targets
    targets.where("data @&gt; (:key =&gt; :value)", key: 'complete', value: 'true')
  end
  </code></pre>
  
  <p>targets.rb</p>
  
  <pre><code>belongs_to :user
  serialize :data, ActiveRecord::Coders::Hstore
  </code></pre>
  
  <p>setup_hstore migration:</p>
  
  <pre><code>class SetupHstore &lt; ActiveRecord::Migration
    def self.up
      execute "CREATE EXTENSION IF NOT EXISTS hstore"
    end
  
    def self.down
      execute "DROP EXTENSION IF EXISTS hstore"
    end
  end
  </code></pre>
  
  <p>Add data column migration:</p>
  
  <pre><code>class AddDataToRecords &lt; ActiveRecord::Migration
    def change
      add_column :records, :data, :hstore
    end
  end
  </code></pre>
  
  <p>Add indexes migration:</p>
  
  <pre><code>class AddHstoreIndexes &lt; ActiveRecord::Migration
    def up
      execute "CREATE INDEX records_gin_data ON records USING GIN(data)"
    end
  
    def down
      execute "DROP INDEX records_gin_data"
    end
  end
  </code></pre>
  
  <p>The Error:</p>
  
  <pre><code>ActiveRecord::StatementInvalid:
  PG::Error: ERROR:  operator does not exist: unknown =&gt; unknown
  LINE 1: ...records"."user_id" = 244 AND (data @&gt; ('complete' =&gt; 'true')...
  </code></pre>
  
  <p>Navicat output when trying to create the extension via a direct query:</p>
  
  <pre><code>CREATE EXTENSION hstore Error : ERROR:  extension "hstore" already exists
  </code></pre>