these are functional indexes which are not supported by Alembic's schema
comparison feature right now. In fact you should see warning that
states "autogenerate skipping functional index %s; not supported by
SQLAlchemy reflection". Just write them out manually in your Alembic
script.
>
>
> Thanks in advance,
> Shailesh
>
>
> On Tuesday, 1 July 2014 10:53:13 UTC+5:30, Michael Bayer wrote:
>
> per the SO answer, you're looking for "CREATE INDEX ON
> publishers((info->>'name'));". Either you can emit this directly as
> a string, or use Index, just as it states:
>
> from sqlalchemy import create_engine, Integer, Index, Table, Column,
> MetaData
> from sqlalchemy.dialects.postgresql import JSON
>
> e = create_engine("postgresql://scott:tiger@localhost/test", echo=True)
>
> m = MetaData()
> publishers = Table('publishers', m, Column('id', Integer),
> Column('info', JSON))
> Index("foo",
publishers.c.info
> <
http://publishers.c.info>['name'].astext)
>>>> <
http://stackoverflow.com/questions/17807030/how-to-create-index-on-json-field-in-postgres-9-3> that
>>>> said otherwise. I haven't had the chance to test it since
>>>> I'm away from my dev environment, but the sqlalchemy docs
>>>> seem to support this idea
>>>> <
http://docs.sqlalchemy.org/en/rel_0_9/dialects/postgresql.html?highlight=json#sqlalchemy.dialects.postgresql.JSON>,
>>>> mentioning the availability of "Index operations."
>>>>
>>>> Unless I'm missing something obvious (very possible), it
>>>> seems like this can be done through sql, but is there a way
>>>> to create an index on a json field through the sqlalchemy
>>>> api? I can't seem to find a way to do this.
>>>>
>>>> Thanks,
>>>> Phil
>>>> --
>>>> You received this message because you are subscribed to the
>>>> Google Groups "sqlalchemy" group.
>>>> To unsubscribe from this group and stop receiving emails
>>>> from it, send an email to
sqlalchemy+...@googlegroups.com.
>>>> To post to this group, send email to
sqlal...@googlegroups.com.
>>>> Visit this group at
>>>>
http://groups.google.com/group/sqlalchemy
>>>> <
http://groups.google.com/group/sqlalchemy>.
>>>> <
https://groups.google.com/d/optout>.
>>>
>>> --
>>> You received this message because you are subscribed to the
>>> Google Groups "sqlalchemy" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to
sqlalchemy+...@googlegroups.com <javascript:>.
>>> <javascript:>.
>>> <
http://groups.google.com/group/sqlalchemy>.
>>> <
https://groups.google.com/d/optout>.
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "sqlalchemy" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to
sqlalchemy+...@googlegroups.com <javascript:>.
>> <javascript:>.
>> <
http://groups.google.com/group/sqlalchemy>.
>> <
https://groups.google.com/d/optout>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
sqlalchemy+...@googlegroups.com
> <mailto:
sqlalchemy+...@googlegroups.com>.
> <mailto:
sqlal...@googlegroups.com>.
> Visit this group at
https://groups.google.com/group/sqlalchemy.