def addIndexes(cls, ifNotExists=True):
 for col in cls._imdbpySchema.cols:
  if col.index:
   idxName = col.index
   colToIdx = col.name
   if col.indexLen:
    colToIdx = {'column': col.name, 'length': col.indexLen}
   if (idxName in [i.name for i in cls.sqlmeta.indexes]):
    continue
   idx = DatabaseIndex(colToIdx, name=idxName)
   cls.sqlmeta.addIndex(idx)
 try:
  cls.createIndexes(ifNotExists)
 except dberrors.OperationalError as e:
  _object_logger.warn(('Skipping creation of the %s.%s index: %s' % (cls.sqlmeta.table, col.name, e)))

def addIndexes ( cls , ifNotExists = True ) : for col in cls . _imdbpySchema . cols : if col . index : idxName = col . index colToIdx = col . name if col . indexLen : colToIdx = { 'column' : col . name , 'length' : col . indexLen } if ( idxName in [ i . name for i in cls . sqlmeta . indexes ] ) : continue idx = DatabaseIndex ( colToIdx , name = idxName ) cls . sqlmeta . addIndex ( idx ) try : cls . createIndexes ( ifNotExists ) except dberrors . OperationalError as e : _object_logger . warn ( ( 'Skipping creation of the %s.%s index: %s' % ( cls . sqlmeta . table , col . name , e ) ) )
create all required indexes .