summaryrefslogtreecommitdiff
path: root/alembic/environment.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-06-02 14:42:09 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-06-02 14:42:09 -0400
commitd4094ff7a76cd4438b15242c7c883333235fc0c7 (patch)
treec525786539ff6fdedce66aad1c5eff05e768bf72 /alembic/environment.py
parentbb160dbf30440144d002810ebd5c5520e37562d7 (diff)
downloadalembic-d4094ff7a76cd4438b15242c7c883333235fc0c7.tar.gz
- [feature] New config argumentrel_0_3_3
"revision_environment=true", causes env.py to be run unconditionally when the "revision" command is run, to support script.py.mako templates with dependencies on custom "template_args". - [feature] Added "template_args" option to configure() so that an env.py can add additional arguments to the template context when running the "revision" command. This requires either --autogenerate or the configuration directive "revision_environment=true".
Diffstat (limited to 'alembic/environment.py')
-rw-r--r--alembic/environment.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/alembic/environment.py b/alembic/environment.py
index 4aeb811..9db519f 100644
--- a/alembic/environment.py
+++ b/alembic/environment.py
@@ -206,6 +206,7 @@ class EnvironmentContext(object):
output_buffer=None,
starting_rev=None,
tag=None,
+ template_args=None,
target_metadata=None,
compare_type=False,
compare_server_default=False,
@@ -273,6 +274,12 @@ class EnvironmentContext(object):
when using ``--sql`` mode.
:param tag: a string tag for usage by custom ``env.py`` scripts.
Set via the ``--tag`` option, can be overridden here.
+ :param template_args: dictionary of template arguments which
+ will be added to the template argument environment when
+ running the "revision" command. Note that the script environment
+ is only run within the "revision" command if the --autogenerate
+ option is used, or if the option "revision_environment=true"
+ is present in the alembic.ini file. New in 0.3.3.
:param version_table: The name of the Alembic version table.
The default is ``'alembic_version'``.
@@ -398,6 +405,8 @@ class EnvironmentContext(object):
opts['starting_rev'] = starting_rev
if tag:
opts['tag'] = tag
+ if template_args and 'template_args' in opts:
+ opts['template_args'].update(template_args)
opts['target_metadata'] = target_metadata
opts['upgrade_token'] = upgrade_token
opts['downgrade_token'] = downgrade_token