1212# Interpret the config file for Python logging.
1313# This line sets up loggers basically.
1414fileConfig (config .config_file_name )
15- logger = logging .getLogger (' alembic.env' )
15+ logger = logging .getLogger (" alembic.env" )
1616
1717
1818def get_engine ():
1919 try :
2020 # this works with Flask-SQLAlchemy<3 and Alchemical
21- return current_app .extensions [' migrate' ].db .get_engine ()
21+ return current_app .extensions [" migrate" ].db .get_engine ()
2222 except (TypeError , AttributeError ):
2323 # this works with Flask-SQLAlchemy>=3
24- return current_app .extensions [' migrate' ].db .engine
24+ return current_app .extensions [" migrate" ].db .engine
2525
2626
2727def get_engine_url ():
2828 try :
29- return get_engine ().url .render_as_string (hide_password = False ).replace (
30- '%' , '%%' )
29+ return get_engine ().url .render_as_string (hide_password = False ).replace ("%" , "%%" )
3130 except AttributeError :
32- return str (get_engine ().url ).replace ('%' , '%%' )
31+ return str (get_engine ().url ).replace ("%" , "%%" )
3332
3433
3534# add your model's MetaData object here
3635# for 'autogenerate' support
3736# from myapp import mymodel
3837# target_metadata = mymodel.Base.metadata
39- config .set_main_option (' sqlalchemy.url' , get_engine_url ())
40- target_db = current_app .extensions [' migrate' ].db
38+ config .set_main_option (" sqlalchemy.url" , get_engine_url ())
39+ target_db = current_app .extensions [" migrate" ].db
4140
4241# other values from the config, defined by the needs of env.py,
4342# can be acquired:
@@ -46,7 +45,7 @@ def get_engine_url():
4645
4746
4847def get_metadata ():
49- if hasattr (target_db , ' metadatas' ):
48+ if hasattr (target_db , " metadatas" ):
5049 return target_db .metadatas [None ]
5150 return target_db .metadata
5251
@@ -64,9 +63,8 @@ def run_migrations_offline():
6463
6564 """
6665 url = config .get_main_option ("sqlalchemy.url" )
67- context .configure (
68- url = url , target_metadata = get_metadata (), literal_binds = True
69- )
66+ context .configure (url = url , target_metadata = get_metadata (),
67+ literal_binds = True )
7068
7169 with context .begin_transaction ():
7270 context .run_migrations ()
@@ -84,23 +82,21 @@ def run_migrations_online():
8482 # when there are no changes to the schema
8583 # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
8684 def process_revision_directives (context , revision , directives ):
87- if getattr (config .cmd_opts , ' autogenerate' , False ):
85+ if getattr (config .cmd_opts , " autogenerate" , False ):
8886 script = directives [0 ]
8987 if script .upgrade_ops .is_empty ():
9088 directives [:] = []
91- logger .info (' No changes in schema detected.' )
89+ logger .info (" No changes in schema detected." )
9290
93- conf_args = current_app .extensions [' migrate' ].configure_args
91+ conf_args = current_app .extensions [" migrate" ].configure_args
9492 if conf_args .get ("process_revision_directives" ) is None :
9593 conf_args ["process_revision_directives" ] = process_revision_directives
9694
9795 connectable = get_engine ()
9896
9997 with connectable .connect () as connection :
10098 context .configure (
101- connection = connection ,
102- target_metadata = get_metadata (),
103- ** conf_args
99+ connection = connection , target_metadata = get_metadata (), ** conf_args
104100 )
105101
106102 with context .begin_transaction ():
0 commit comments