fantasy/__init__.py
def smart_migrate(app, migrations_root):
    """如果存在migration且指定为primary_node则执行migrate操作"""

    db = app.db
    if os.path.exists(migrations_root) and \
            os.environ['FANTASY_PRIMARY_NODE'] != 'no':
        from flask_migrate import (Migrate,
                                   upgrade as migrate_upgrade)

        migrate = Migrate(app, db, directory=migrations_root)
        migrate.init_app(app, db)
        migrate_upgrade(migrations_root)
        pass
    pass
def smart_migrate(app, migrations_root):
    """如果存在migration且指定为primary_node则执行migrate操作"""

    db = app.db
    if os.path.exists(migrations_root) and \
            os.environ['FANTASY_PRIMARY_NODE'] != 'no':
        from flask_migrate import (Migrate,
                                   upgrade as migrate_upgrade)

        migrate = Migrate(app, db, directory=migrations_root)
        migrate.init_app(app, db)
        migrate_upgrade(migrations_root)
        pass
    pass
def smart_migrate ( app , migrations_root ) : db = app . db if os . path . exists ( migrations_root ) and os . environ [ 'FANTASY_PRIMARY_NODE' ] != 'no' : from flask_migrate import ( Migrate , upgrade as migrate_upgrade ) migrate = Migrate ( app , db , directory = migrations_root ) migrate . init_app ( app , db ) migrate_upgrade ( migrations_root ) pass pass
如果存在migration且指定为primary_node则执行migrate操作
如果存在migration且指定为primary_node则执行migrate操作