On Tue, Sep 08, 2009 at 13:06 +0200, Wolodja Wentland wrote: > is it possible to drop primary key indexes from within SA? I already > found the table.indexes set, but it does not contain the primary key > index. I can therefore drop all indexes for a table except the primary > key one.
I did some investigation and found that the primary key index is generated automagically by PostgreSQL rather than SA. This is because i declare some columns with 'primary_key=True' which causes psql to create a primary key constraint and an index. If i connect to the db in question and reflect the tables it is unfortunately not possible to drop any pkey constraint, because the .drop() method if not present in sa.schema.PrimaryKeyConstraint but only in migrate.changeset.constraint.PrimaryKeyConstraint. I create all PrimaryKeyConstraints explicitly now and use the PrimaryKeyConstraint class from migrate. The problem i am facing now is that i do not get instances of migrate's PrimaryKeyConstraint but rather SA's one if i work on the constraints like exemplified in the following code snippet: --- snip --- ... metadata = MetaData() metadata.bind = engine self._metadata.reflect() tbl = self._metadata.tables[table_name] pkc = [ con for con in tbl.constraints if isinstance(con, PrimaryKeyConstraint) ][0] log.debug('Primary key constraint for table [%s] on: %s'%( table_name, pkc.columns.keys())) log.debug('Dropping pkey constraint ...') pkc.drop() ^^^^^^^^^^ This method is not present because i get instances from SA's classes not migrate's --- snip --- How can i tackle this problem? Any advise is welcome! with kind regards Wolodja Wentland
signature.asc
Description: Digital signature