1. Mike Bayer
  2. alembic


Issue #83 resolved

"alembic downgrade -1" fails with spurious # of arguments error

David Ripton
created an issue

Running alembic 0.4.0 (from pip), on a Fedora 17 box, with SQLAlchemy 0.7.9 (from pip), and mysql as the DB.

[dripton@dripton sqlalchemy]$ alembic downgrade -1 INFO [alembic.migration] Context impl MySQLImpl. INFO [alembic.migration] Will assume non-transactional DDL. INFO [alembic.migration] Running downgrade 5896b53ac5b4 -> 3d948a0be96 Traceback (most recent call last): File "/usr/bin/alembic", line 9, in <module> load_entry_point('alembic==0.4.0', 'console_scripts', 'alembic')() File "/usr/lib/python2.7/site-packages/alembic/config.py", line 255, in main CommandLine(prog=prog).main(argv=argv) File "/usr/lib/python2.7/site-packages/alembic/config.py", line 250, in main self.run_cmd(cfg, options) File "/usr/lib/python2.7/site-packages/alembic/config.py", line 241, in run_cmd dict((k, getattr(options, k)) for k in kwarg) File "/usr/lib/python2.7/site-packages/alembic/command.py", line 148, in downgrade script.run_env() File "/usr/lib/python2.7/site-packages/alembic/script.py", line 191, in run_env util.load_python_file(self.dir, 'env.py') File "/usr/lib/python2.7/site-packages/alembic/util.py", line 185, in load_python_file module = imp.load_source(module_id, path, open(path, 'rb')) File "alembic/env.py", line 70, in <module> run_migrations_online() File "alembic/env.py", line 63, in run_migrations_online context.run_migrations() File "<string>", line 7, in run_migrations File "/usr/lib/python2.7/site-packages/alembic/environment.py", line 494, in run_migrations self.get_context().run_migrations(kw) File "/usr/lib/python2.7/site-packages/alembic/migration.py", line 211, in run_migrations change(**kw) TypeError: downgrade() takes exactly 1 argument (0 given)

I get the same traceback if I use the prefix of any filename in alembic/versions as the argument to "alembic downgrade"

Comments (7)

  1. David Ripton reporter

    The traceback was formatted correctly when I typed it in, sorry. Bitbucket's tracker appears to have decided that my newlines were unimportant.

  2. Mike Bayer repo owner

    did you modify your script.py.mako to receive positional arguments within the downgrade() function ? only keyword arguments are supported.

    edit: i misstated this, i meant, you need to pass keyword arguments to context.run_migrations() if you've specified arguments in your downgrade().

  3. David Ripton reporter

    (Reply via dri...@ripton.net):

    Aha! My downgrade function (which was converted from a sqlalchemy-migrate downgrade function) took an argument, which is not allowed. Sorry, my bug not yours.

  4. Log in to comment