Skip to content

Commit

Permalink
allow -x argument for migrate command
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Mundt committed Feb 16, 2017
1 parent 5f34c5c commit 3293d83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions flask_migrate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,14 @@ def revision(directory=None, message=None, autogenerate=False, sql=False,
@MigrateCommand.option('-d', '--directory', dest='directory', default=None,
help=("migration script directory (default is "
"'migrations')"))
@MigrateCommand.option('-x', '--x-arg', dest='x_arg', default=None,
action='append', help=("Additional arguments consumed "
"by custom env.py scripts"))
def migrate(directory=None, message=None, sql=False, head='head', splice=False,
branch_label=None, version_path=None, rev_id=None):
branch_label=None, version_path=None, rev_id=None, x_arg=None):
"""Alias for 'revision --autogenerate'"""
config = current_app.extensions['migrate'].migrate.get_config(
directory, opts=['autogenerate'])
directory, opts=['autogenerate'], x_arg=x_arg)
if alembic_version >= (0, 7, 0):
command.revision(config, message, autogenerate=True, sql=sql,
head=head, splice=splice, branch_label=branch_label,
Expand Down
6 changes: 4 additions & 2 deletions flask_migrate/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ def revision(directory, message, autogenerate, sql, head, splice, branch_label,
@click.option('--rev-id', default=None,
help=('Specify a hardcoded revision id instead of generating '
'one'))
@click.option('-x', '--x-arg', multiple=True,
help='Additional arguments consumed by custom env.py scripts')
@with_appcontext
def migrate(directory, message, sql, head, splice, branch_label, version_path,
rev_id):
rev_id, x_arg):
"""Autogenerate a new revision file (Alias for 'revision --autogenerate')"""
_migrate(directory, message, sql, head, splice, branch_label, version_path,
rev_id)
rev_id, x_arg)


@db.command()
Expand Down

0 comments on commit 3293d83

Please sign in to comment.