How to declare ORM class with index that in postgress is created with GREATEST

11 views
Skip to first unread message

Yoav Kopfstein

unread,
Mar 13, 2023, 12:05:14 PM3/13/23
to sqlalchemy
Hi,
I would like to declare an index in orm class with sqlalchemy 1.4
The index is created in postgres with this command:

create index index_name
    on table_name (GREATEST(field_1, field_2));

how can I do it?     (with __table_args__ or without )
thanks

Cameron Simpson

unread,
Mar 13, 2023, 4:25:37 PM3/13/23
to sqlal...@googlegroups.com
Do you have the rest of your table definiton to hand for comparison?

Have you see this example in the core docs:
https://docs.sqlalchemy.org/en/14/core/constraints.html#indexes

Cheers,
Cameron Simpson <c...@cskk.id.au>
Reply all
Reply to author
Forward
0 new messages