Functions | |
void | cleanUp (const std::string &connectionString, std::set< std::string > exclusionList=std::set< std::string >()) |
void ora::SchemaUtils::cleanUp | ( | const std::string & | connectionString, |
std::set< std::string > | exclusionList = std::set<std::string>() |
||
) |
Definition at line 22 of file SchemaUtils.cc.
References python::IdGenerator::schema, python::CommonUtils::session, lumiQTWidget::t, and dataDML::tables.
Referenced by TestFunct::DropTables().
{ coral::ConnectionService connServ; std::auto_ptr<coral::ISessionProxy> session( connServ.connect( connectionString, coral::Update )); session->transaction().start(); try{ coral::ISchema& schema = session->nominalSchema(); std::set<std::string> tables = schema.listTables(); for( std::set<std::string>::const_iterator iEx = exclusionList.begin(); iEx != exclusionList.end(); ++iEx ){ tables.erase( *iEx ); } for( std::set<std::string>::const_iterator iT = tables.begin(); iT != tables.end(); ++iT ){ coral::ITable& t = schema.tableHandle( *iT ); int numFKs = t.description().numberOfForeignKeys(); for( int ifk=0; ifk < numFKs; ifk++ ){ // workaround: since the dropFK triggers a commit, the fk list is reset. therefore, always drop the fk id=0!!! t.schemaEditor().dropForeignKey( t.description().foreignKey( 0 ).name() ); }; } for( std::set<std::string>::const_iterator iT = tables.begin(); iT != tables.end(); ++iT ){ schema.dropIfExistsTable( *iT ); } session->transaction().commit(); } catch ( ... ){ session->transaction().rollback(); throw; } }