From 57c82f35366ea9122908e3b0cbdcf536d430c2de Mon Sep 17 00:00:00 2001 From: Brian Cappello Date: Mon, 5 Dec 2016 14:30:25 -0500 Subject: [PATCH] support passing alembic context kwargs from constructor into init_app --- flask_migrate/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/flask_migrate/__init__.py b/flask_migrate/__init__.py index b7908c7..f59d063 100755 --- a/flask_migrate/__init__.py +++ b/flask_migrate/__init__.py @@ -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)