<s> from __future__ import with_statement <EOL> import logging <EOL> from logging . config import fileConfig <EOL> from alembic import context <EOL> from flask . ext . appbuilder import Base <EOL> from sqlalchemy import engine_from_config , pool <EOL> config = context . config <EOL> fileConfig ( config . config_file_name ) <EOL> logger = logging . getLogger ( '<STR_LIT>' ) <EOL> from flask import current_app <EOL> config . set_main_option ( '<STR_LIT>' , <EOL> current_app . config . get ( '<STR_LIT>' ) ) <EOL> target_metadata = Base . metadata <EOL> def run_migrations_offline ( ) : <EOL> """<STR_LIT>""" <EOL> url = config . get_main_option ( "<STR_LIT>" ) <EOL> context . configure ( url = url ) <EOL> with context . begin_transaction ( ) : <EOL> context . run_migrations ( ) <EOL> def run_migrations_online ( ) : <EOL> """<STR_LIT>""" <EOL> def process_revision_directives ( context , revision , directives ) : <EOL> if getattr ( config . cmd_opts , '<STR_LIT>' , False ) : <EOL> script = directives [ <NUM_LIT:0> ] <EOL> if script . upgrade_ops . is_empty ( ) : <EOL> directives [ : ] = [ ] <EOL> logger . info ( '<STR_LIT>' ) <EOL> engine = engine_from_config ( config . get_section ( config . config_ini_section ) , <EOL> prefix = '<STR_LIT>' , <EOL> poolclass = pool . NullPool ) <EOL> connection = engine . connect ( ) <EOL> context . configure ( connection = connection , <EOL> target_metadata = target_metadata , <EOL> process_revision_directives = process_revision_directives , <EOL> ** current_app . extensions [ '<STR_LIT>' ] . configure_args ) <EOL> try : <EOL> with context . begin_transaction ( ) : <EOL> context . run_migrations ( ) <EOL> finally : <EOL> connection . close ( ) <EOL> if context . is_offline_mode ( ) : <EOL> run_migrations_offline ( ) <EOL> else : <EOL> run_migrations_online ( ) </s>
