Make sure the migrations table is set up in the database.

def assure_migrations_table_setup(db):
    """
    Make sure the migrations table is set up in the database.
    """
    from mig.models import MigrationData

    if not MigrationData.__table__.exists(db.bind):
        MigrationData.metadata.create_all(
            db.bind, tables=[MigrationData.__table__])