title: How to Create Gin Indices Concurrently? POSTGRES & Rails 4.2
body: <p>I am following the thoughtbot tutorial on multi-index full-text search using postgresql and rails 4. And I can't seem to get the indices migrations to work. I have tried</p>
  
  <pre><code>  disable_ddl_transaction!  
    def change
      add_index(:cards, :object, using: 'gin', algorithm: :concurrently)
      add_index(:cards, :content, using: 'gin', algorithm: :concurrently)
      add_index(:tags, :name, using: 'gin', algorithm: :concurrently)     
    end
  </code></pre>
  
  <p>and</p>
  
  <pre><code>  def up
      ActiveRecord::Base.connection.execute &lt;&lt;-SQL
      CREATE INDEX CONCURRENTLY index_cards_on_object ON cards USING gin(to_tsvector('english', object));
      CREATE INDEX CONCURRENTLY index_cards_on_content ON cards USING gin(to_tsvector('english', content));
      CREATE INDEX CONCURRENTLY index_tags_on_name ON tags USING gin(to_tsvector('english', name));
     SQL
   end
   def down
      ActiveRecord::Base.connection.execute &lt;&lt;-SQL
      DROP INDEX index_cards_on_object;
      DROP INDEX index_cards_on_content;
      DROP INDEX index_tags_on_name;
    SQL
  end
  </code></pre>
  
  <p>I get the following errors (rescpectively)</p>
  
  <blockquote>
    <p>PG::UndefinedObject: ERROR:  data type character varying has no default operator class for access method "gin"</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>ActiveRecord::StatementInvalid: PG::UndefinedObject: ERROR:  data type character varying has no default operator class for access method "gin"
    PG::SyntaxError: ERROR:  syntax error at or near "CREATE"</p>
  </blockquote>
  
  <p>All help and insight welcomed, thank you</p>