The changeset method in migrate/versioning/repository.py (around line 200), does not work for timestamped version numbers. The list comprehension which determines the set of versions between :start: and :end: assumes that the versions are 1 apart from each other. This is obviously wrong (most of the time) when using timestamped version numbers, resulting in the following traceback:
Traceback (most recent call last):
File "/Users/andrew/work/incubator/hilo-backend/venv/bin/migrate", line 11, in <module>
sys.exit(main())
File "/Users/andrew/work/incubator/hilo-backend/venv/lib/python3.4/site-packages/migrate/versioning/shell.py", line 209, in main
ret = command_func(**kwargs)
File "/Users/andrew/work/incubator/hilo-backend/venv/lib/python3.4/site-packages/migrate/versioning/api.py", line 186, in upgrade
return _migrate(url, repository, version, upgrade=True, err=err, **opts)
File "<decorator-gen-15>", line 2, in _migrate
File "/Users/andrew/work/incubator/hilo-backend/venv/lib/python3.4/site-packages/migrate/versioning/util/__init__.py", line 160, in with_engine
return f(*a, **kw)
File "/Users/andrew/work/incubator/hilo-backend/venv/lib/python3.4/site-packages/migrate/versioning/api.py", line 345, in _migrate
changeset = schema.changeset(version)
File "/Users/andrew/work/incubator/hilo-backend/venv/lib/python3.4/site-packages/migrate/versioning/schema.py", line 82, in changeset
changeset = self.repository.changeset(database, start_ver, version)
File "/Users/andrew/work/incubator/hilo-backend/venv/lib/python3.4/site-packages/migrate/versioning/repository.py", line 225, in changeset
changes = [self.version(v).script(database, op) for v in versions]
File "/Users/andrew/work/incubator/hilo-backend/venv/lib/python3.4/site-packages/migrate/versioning/repository.py", line 225, in <listcomp>
changes = [self.version(v).script(database, op) for v in versions]
File "/Users/andrew/work/incubator/hilo-backend/venv/lib/python3.4/site-packages/migrate/versioning/repository.py", line 189, in version
return self.versions.version(*p, **k)
File "/Users/andrew/work/incubator/hilo-backend/venv/lib/python3.4/site-packages/migrate/versioning/version.py", line 163, in version
return self.versions[VerNum(vernum)]
KeyError: <VerNum(1)>
Closes-Bug: 1512561
This is a quick work-around. The code for sequentially versioned schemas
is left unchanged, but this approach would probably work for those
version numbers as well.
All tests are passing on python 2.x. On python 3.x, there are 4
failures, but none appear related to this change.