Closed fj closed 9 years ago
@fj this works:
class AddIndexes < ActiveRecord::Migration
def up
add_index :blog_posts, using: :gin, expression: "(metadata -> 'tags')", name: 'idx_blog_posts_tags'
end
def down
remove_index :blog_posts, name: :idx_blog_posts_tags
end
end
You can already achieve the GIN index on the whole column with plain AR, just use using: :gin
in the index
Agreed, this is now handled already by schema_plus
. Closing.
Postgresql permits indexes on specific keys in JSONB fields. SchemaPlus can handle indices on the whole JSONB column, like any other column, but it doesn't seem to have a syntax (that I could find) for doing so on a specific key.
In Postgresql, this would look like:
for a specific-key index, or
for an index on the whole column.