docs: def configure_replicator_database(host, port, username=None, password=None):
      """
      Connects to dabatase, checks the version and creates the
      design document used by feat (if it doesn't exist).
  
      @returns: IDatabaseConnection bound to _replicator database
      """
      database = driver.Database(host, port, '_replicator', username, password)
      connection = database.get_connection()
      version = yield database.get_version()
      if version < (1, 1, 0):
          database.disconnect()
          raise ValueError("Found couchdb version %r. "
                           "_replicator database has been introduced in 1.1.0." %
                           (version, ))
      design_docs = view.DesignDocument.generate_from_views([Replications])
      for doc in design_docs:
          try:
              doc2 = yield connection.get_document(doc.doc_id)
              if doc.views != doc2.views or doc.filters != doc2.filters:
                  doc.rev = doc2.rev
                  yield connection.save_document(doc)
  
          except NotFoundError:
              yield connection.save_document(doc)
      defer.returnValue(connection)