On May 23, 2013, at 8:06 PM, Mike Bissell <[email protected]> wrote:

> How might I convince SQLAlchemy 0.7.9 to create a newly added index on a 
> table in the event that the index doesn't already exist? This new index is 
> created as a member of __table_args__; it is not instantiated with 
> index=True. I have many such index objects to create.


an Index has a create() method for single creates.

> 
> I did check stackoverflow, and their unsatisfactory advice was simply to cut 
> and paste the generated DDL:
> 
>    
> http://stackoverflow.com/questions/14419299/adding-indexes-to-sqlalchemy-models-after-table-creation

that answer is a disaster and I've added my own answer to that question, and I 
would imagine it threw you off the path here.

> If this feature doesn't exist, I would settle for a function that would take 
> a table and conditionally create any missing pieces (specifically indexes).
> 
> As a last resort, is the correct way to do this simply to call Index.create 
> for each index I make?

OK confused, you apparently know about index.create(), so what exactly is the 
feature you're looking for as far as conditionally creating missing pieces ?   
Other kinds of "missing pieces" like constraints use the AddConstraint() 
construct,plenty of detail on that here: 
http://docs.sqlalchemy.org/en/rel_0_8/core/schema.html#controlling-ddl-sequences
 , note however we don't support "checking" for individual table constraints 
right now (indexes are a separate concern).

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to