Skip to content

Commit

Permalink
support passing alembic context kwargs from constructor into init_app
Browse files Browse the repository at this point in the history
  • Loading branch information
briancappello authored and miguelgrinberg committed Dec 9, 2016
1 parent 67baa5d commit 57c82f3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions flask_migrate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,18 @@ def __init__(self, app=None, db=None, directory='migrations', **kwargs):
self.configure_callbacks = []
self.db = db
self.directory = directory
self.alembic_ctx_kwargs = kwargs
if app is not None and db is not None:
self.init_app(app, db, directory, **kwargs)
self.init_app(app, db, directory)

def init_app(self, app, db=None, directory=None, **kwargs):
self.db = db or self.db
self.directory = directory or self.directory
self.alembic_ctx_kwargs.update(kwargs)
if not hasattr(app, 'extensions'):
app.extensions = {}
app.extensions['migrate'] = _MigrateConfig(self, self.db, **kwargs)
app.extensions['migrate'] = _MigrateConfig(self, self.db,
**self.alembic_ctx_kwargs)

def configure(self, f):
self.configure_callbacks.append(f)
Expand Down

0 comments on commit 57c82f3

Please sign in to comment.