'Ensure indexes on collections.'

def _ensure_indexes(self, database):

    messages = database[self.messages_collection]
    messages.ensure_index([(u'queue', 1), (u'priority', 1), (u'_id', 1)], background=True)
    database[self.broadcast_collection].ensure_index([(u'queue', 1)])
    routing = database[self.routing_collection]
    routing.ensure_index([(u'queue', 1), (u'exchange', 1)])
    if self.ttl:
        messages.ensure_index([(u'expire_at', 1)], expireAfterSeconds=0)
        routing.ensure_index([(u'expire_at', 1)], expireAfterSeconds=0)
        database[self.queues_collection].ensure_index([(u'expire_at', 1)], expireAfterSeconds=0)
