@app.before_first_request
def check_db_schema():
    if db.engine.name != 'sqlite':
        version = AlembicVersion.query.scalar()
        assert version, "no schema revision found. please run '%s db upgrade'" % __file__
        migrations = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'migrations', 'versions')

        revisions = [_parse_revision(os.path.join(migrations, filename)) for filename in os.listdir(migrations) if filename.endswith('.py')]
        max_revision = max(revisions)
        db_version = int(version.version_num)
        assert db_version == max_revision, "old database schema found: revision %d. please run '%s db upgrade' to upgrade to revision %d" % (db_version, __file__, max_revision)
dataset/ETHPy150Open bwaldvogel/openmoves/openmoves.py/check_db_schema/original