def run_migrations_online():
<EOL>def process_revision_directives(context, revision, directives):<EOL><INDENT>if getattr(config.cmd_opts, '<STR_LIT>', False):<EOL><INDENT>script = directives[<NUM_LIT:0>]<EOL>if len(script.upgrade_ops_list) >= len(bind_names) + <NUM_LIT:1>:<EOL><INDENT>empty = True<EOL>for upgrade_ops in script.upgrade_ops_list:<EOL><INDENT>if not upgrade_ops.is_empty():<EOL><INDENT>empty = False<EOL><DEDENT><DEDENT>if empty:<EOL><INDENT>directives[:] = []<EOL>logger.info('<STR_LIT>')<EOL><DEDENT><DEDENT><DEDENT><DEDENT>engines = {<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': engine_from_config(<EOL>config.get_section(config.config_ini_section),<EOL>prefix='<STR_LIT>',<EOL>poolclass=pool.NullPool,<EOL>)<EOL>}<EOL>}<EOL>for name in bind_names:<EOL><INDENT>engines[name] = rec = {}<EOL>rec['<STR_LIT>'] = engine_from_config(<EOL>context.config.get_section(name),<EOL>prefix='<STR_LIT>',<EOL>poolclass=pool.NullPool)<EOL><DEDENT>for name, rec in engines.items():<EOL><INDENT>engine = rec['<STR_LIT>']<EOL>rec['<STR_LIT>'] = conn = engine.connect()<EOL>if USE_TWOPHASE:<EOL><INDENT>rec['<STR_LIT>'] = conn.begin_twophase()<EOL><DEDENT>else:<EOL><INDENT>rec['<STR_LIT>'] = conn.begin()<EOL><DEDENT><DEDENT>try:<EOL><INDENT>for name, rec in engines.items():<EOL><INDENT>logger.info("<STR_LIT>" % (name or '<STR_LIT>'))<EOL>context.configure(<EOL>connection=rec['<STR_LIT>'],<EOL>upgrade_token="<STR_LIT>" % name,<EOL>downgrade_token="<STR_LIT>" % name,<EOL>target_metadata=get_metadata(name),<EOL>process_revision_directives=process_revision_directives,<EOL>**current_app.extensions['<STR_LIT>'].configure_args<EOL>)<EOL>context.run_migrations(engine_name=name)<EOL><DEDENT>if USE_TWOPHASE:<EOL><INDENT>for rec in engines.values():<EOL><INDENT>rec['<STR_LIT>'].prepare()<EOL><DEDENT><DEDENT>for rec in engines.values():<EOL><INDENT>rec['<STR_LIT>'].commit()<EOL><DEDENT><DEDENT>except:<EOL><INDENT>for rec in engines.values():<EOL><INDENT>rec['<STR_LIT>'].rollback()<EOL><DEDENT>raise<EOL><DEDENT>finally:<EOL><INDENT>for rec in engines.values():<EOL><INDENT>rec['<STR_LIT>'].close()<EOL><DEDENT><DEDENT>
Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.