Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dupe entries in alembic_versions can break revision logic #314

sqlalchemy-bot opened this issue Aug 3, 2015 · 3 comments

dupe entries in alembic_versions can break revision logic #314

sqlalchemy-bot opened this issue Aug 3, 2015 · 3 comments
bug Something isn't working versioning model


Copy link

Migrated issue, originally created by Michael Bayer (@zzzeek)



sqlite> select * from alembic_version;

this should raise an error on the stamp, but versioning fails:


Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 442, in <module>
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 439, in main
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 433, in main
    self.run_cmd(cfg, options)
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 416, in run_cmd
    **dict((k, getattr(options, k)) for k in kwarg)
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 193, in downgrade
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 390, in run_env
    util.load_python_file(self.dir, '')
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 244, in load_python_file
    module = load_module_py(module_id, path)
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 68, in load_module_py
    module_id, path).load_module(module_id)
  File "<frozen importlib._bootstrap>", line 539, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1614, in load_module
  File "<frozen importlib._bootstrap>", line 596, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 1220, in load
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "foo/", line 70, in <module>
  File "foo/", line 65, in run_migrations_online
  File "<string>", line 7, in run_migrations
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 738, in run_migrations
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 302, in run_migrations
    for step in self._migrations_fn(heads, self):
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 182, in downgrade
    return script._downgrade_revs(revision, rev)
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 315, in _downgrade_revs
    current_rev, destination)
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 512, in iterate_revisions
    inclusive, assert_relative_length
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 450, in _relative_iterate
    inclusive=inclusive, implicit_base=implicit_base))
  File "/Users/classic/tmp/alembic_0_7_7/alembic/", line 672, in _iterate_revisions
KeyError: '32f69b44319'

Copy link

Michael Bayer (@zzzeek) wrote:

if we have an 0.7.8, then backport. otherwise keep it in 0.8.

Copy link

Michael Bayer (@zzzeek) wrote:

  • Fixed bug where in the erroneous case that alembic_version contains
    duplicate revisions, some commands would fail to process the
    version history correctly and end up with a KeyError. The fix
    allows the versioning logic to proceed, however a clear error is
    emitted later when attempting to update the alembic_version table.
    fixes dupe entries in alembic_versions can break revision logic #314


Copy link

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added versioning model bug Something isn't working labels Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
bug Something isn't working versioning model
None yet

No branches or pull requests

1 participant