1. Michael Bayer
  2. alembic
  3. Issues


Issue #216 resolved

Postgresql index with ctid breaks alembic autogenerate

Scott Milliken
created an issue

An index on the implicit postgresql system column "ctid" in an existing database will cause alembic to raise a KeyError during autogenerate.


CREATE INDEX ix_example_ctid ON (ctid);

Marking this as trivial because it's not a blocking issue for us, and it's a bit of an edge case. Thought I'd report it anyway, but feel free to close this if you don't think it's important.


Traceback (most recent call last):
  File "./bin/alembic", line 112, in <module>
    sys.exit(alembic.config.main(['-c', config_file] + sys.argv[1:]))
  File "./alembic-0.6.5-py2.7.egg/alembic/config.py", line 298, in main
  File "./alembic-0.6.5-py2.7.egg/alembic/config.py", line 293, in main
    self.run_cmd(cfg, options)
  File "./alembic-0.6.5-py2.7.egg/alembic/config.py", line 279, in run_cmd
    **dict((k, getattr(options, k)) for k in kwarg)
  File "./alembic-0.6.5-py2.7.egg/alembic/command.py", line 97, in revision
  File "./alembic-0.6.5-py2.7.egg/alembic/script.py", line 203, in run_env
    util.load_python_file(self.dir, 'env.py')
  File "./alembic-0.6.5-py2.7.egg/alembic/util.py", line 212, in load_python_file
    module = load_module_py(module_id, path)
  File "./alembic-0.6.5-py2.7.egg/alembic/compat.py", line 58, in load_module_py
    mod = imp.load_source(module_id, path, fp)
  File "./src/mixrank/data/alembic_citus/env.py", line 110, in <module>
  File "./src/mixrank/data/alembic_citus/env.py", line 103, in run_migrations_online
  File "<string>", line 7, in run_migrations
  File "./alembic-0.6.5-py2.7.egg/alembic/environment.py", line 688, in run_migrations
  File "./alembic-0.6.5-py2.7.egg/alembic/migration.py", line 242, in run_migrations
  File "./alembic-0.6.5-py2.7.egg/alembic/command.py", line 83, in retrieve_migrations
    autogen._produce_migration_diffs(context, template_args, imports)
  File "./alembic-0.6.5-py2.7.egg/alembic/autogenerate/api.py", line 137, in _produce_migration_diffs
    autogen_context, object_filters, include_schemas)
  File "./alembic-0.6.5-py2.7.egg/alembic/autogenerate/api.py", line 213, in _produce_net_changes
    inspector, metadata, diffs, autogen_context)
  File "./alembic-0.6.5-py2.7.egg/alembic/autogenerate/compare.py", line 65, in _compare_tables
    inspector.reflecttable(t, None)
  File "./SQLAlchemy-0.9.6-py2.7-linux-x86_64.egg/sqlalchemy/engine/reflection.py", line 588, in reflecttable
    for c in columns
  File "./SQLAlchemy-0.9.6-py2.7-linux-x86_64.egg/sqlalchemy/util/_collections.py", line 156, in __getitem__
    return self._data[key]
KeyError: u'ctid'

Comments (2)

  1. Log in to comment