'Create all required foreign keys.'

def addForeignKeys(self, mapTables, ifNotExists=True):

    if (not HAS_MC):
        return
    countCols = 0
    for col in self._imdbpySchema.cols:
        countCols += 1
        if (not col.foreignKey):
            continue
        fks = col.foreignKey.split('.', 1)
        foreignTableName = fks[0]
        if (len(fks) == 2):
            foreignColName = fks[1]
        else:
            foreignColName = 'id'
        foreignColName = mapTables[foreignTableName].colMap.get(foreignColName, foreignColName)
        thisColName = self.colMap.get(col.name, col.name)
        thisCol = self.table.columns[thisColName]
        foreignTable = mapTables[foreignTableName].table
        foreignCol = getattr(foreignTable.c, foreignColName)
        fkName = ('fk_%s_%s_%d' % (foreignTable.name, foreignColName, countCols))
        constrain = migrate.changeset.ForeignKeyConstraint([thisCol], [foreignCol], name=fkName)
        try:
            constrain.create()
        except exc.OperationalError:
            continue
