def loadSchema(db, doMigrate=False):
    global VERSION
    try:
        version =  checkVersion(db)
    except sqlerrors.SchemaVersionError, e:
        version = e.args[0]
    logMe(1, "current =", version, "required =", VERSION)
    # load the current schema object list
    db.loadSchema()

    # avoid a recursive import by importing just what we need
    from conary.server import migrate

    # expedite the initial repo creation
    if version == 0:
        createSchema(db)
        db.loadSchema()
        setVer = migrate.majorMinor(VERSION)
        return db.setVersion(setVer)
    # test if  the repo schema is newer than what we understand
    # (by major schema number)
    if version.major > VERSION.major:
        raise sqlerrors.SchemaVersionError("""
        The repository schema version is newer and incompatible with
        this code base. You need to update conary code to a version
        that undersand repo schema %s""" % version, version)
    # now we need to perform a schema migration
    if version.major < VERSION.major or not doMigrate:
        raise sqlerrors.SchemaVersionError("""
        Repository schema needs to have a major schema update performed.
        Please run server.py with --migrate option to perform this upgrade.
        """, version, VERSION)
    # now the version.major is smaller than VERSION.major - but is it too small?
    # we only support migrations from schema 13 on
    if version < 13:
        raise sqlerrors.SchemaVersionError("""
        Repository schemas from Conary versions older than 1.0 are not
        supported. Contact rPath for help converting your repository to
        a supported version.""", version)
    # compatible schema versions have the same major
    if version.major == VERSION.major and not doMigrate:
        return version
    # if we reach here, a schema migration is needed/requested
    version = migrate.migrateSchema(db)
    db.loadSchema()
    # run through the schema creation to create any missing objects
    logMe(2, "checking for/initializing missing schema elements...")
    createSchema(db)
    if version > 0 and version.major != VERSION.major:
        # schema creation/conversion failed. SHOULD NOT HAPPEN!
        raise sqlerrors.SchemaVersionError("""
        Schema migration process has failed to bring the database
        schema version up to date. Please report this error at
        http://issues.rpath.com/.

        Current schema version is %s; Required schema version is %s.
        """ % (version, VERSION))
    db.loadSchema()
    return VERSION
dataset/ETHPy150Open sassoftware/conary/conary/server/schema.py/loadSchema/operator `and` -> `or`