SchemaPlus / schema_plus

SchemaPlus provides a collection of enhancements and extensions to ActiveRecord
Other
679 stars 84 forks source link

Wrong index export in jsonb column #212

Closed javiyu closed 9 years ago

javiyu commented 9 years ago

I have a migration creating an index in a jsonb with a SQL like:

CREATE INDEX index_name ON table USING gin ((column->'field'));

The migration works fine but in schema.rb I got: t.index name: "index_contexts_on_context_activities_category", using: :gin, expression: "(context_activities -> 'category'::text)"

And it seems to no have the correct syntax: ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "->"

Using: schema_plus 2.0.0.pre11, rails 4.2.1, postgres 9.4

ronen commented 9 years ago

@javiyu Thanks for the bug report, sorry for the trouble. Turns out what is in schema.rb is actually correct, but t.index had a bug which I've fixed.

The fix was actually in the gem schema_plus_pg_indexes -- so make sure when you update you get version 0.1.4 of that gem, which is the new release.

javiyu commented 9 years ago

Thanks @ronen , working perfectly now!