- edited description
this works in general, but fails on at least the Postgresql dialect because it is linking each expression to a column. See https://bitbucket.org/zzzeek/alembic/issue/222/support-functional-indexes-with for how alembic works around this.
from sqlalchemy import *
from sqlalchemy.schema import CreateIndex
from sqlalchemy.dialects import postgresql
m = MetaData()
t = Table('x', m)
idx = Index('foo', text("lower(c)"))
idx._set_parent(t)
print CreateIndex(idx).compile(dialect=postgresql.dialect())
output:
CREATE INDEX foo ON x ()
Index should be a lot more forgiving for indexes that have non-column expressions in it, and we should also provide for a "table" keyword.