Watching http://railscasts.com/episodes/345-hstore
I've decided to implement some hstore columns.
From my understanding
execute "CREATE INDEX products_gin_properties ON products USING GIN(properties)"
or better written as (Rails 4):
add_index :products, :properties, using: :gin
Both only creates an index on the hstore column.
How would I add an index on a key in a hstore column? Lookin around, I could do something similar to:
execute "CREATE INDEX products_properties_name ON products (properties -> 'name')"
However, is there a Rails 4 approach to doing this?
just looking at the source code here: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L418
def add_index(table_name, column_name, options = {}) #:nodoc:
index_name, index_type, index_columns, index_options, index_algorithm, index_using = add_index_options(table_name, column_name, options)
execute "CREATE #{index_type} INDEX #{index_algorithm} #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} #{index_using} (#{index_columns})#{index_options}"
end
index_columns
is a comma separated list of columns.
it does not seem like it is supported.