Broadly speaking -- yes, sounds interesting; the trick will be coming
up with an API that *isn't* PostgreSQL specific.
Off the top of my head, I would look at this problem as the problem of
configuring the types of index that are to be created. db_index is
currently treated as a boolean yes/no; if you say yes, it creates an
index (or, in the case of PostgresSQL, indices); if you say no, it
doesn't. To me, what you're talking about is turning a True/False
option into something that can be explicitly configured (with some
sort of fallback so that "True" is the default index collection).
This would need to be functionally driven -- e.g., "I want to add an
index that allows for partial matches", or "I want to add a
case-insensitive index" -- not exposing literal database syntax or
options. On some databases, some of these "functions" would be no-ops,
or subsumed by other index functions (so MySQL, for example, will only
create one index on CharFields).
There is an analogous ticket around dealing with adding
composite/multicolumn indices:
https://code.djangoproject.com/ticket/5805
I don't know if there's any potential for overlap when it comes to the
API here, but it might be worth exploring.
Yours,
Russ Magee %-)