Alembic - 自我生成失败了

时间:2014-01-11 00:36:26

标签: python sqlalchemy alembic

我正在运行的命令:

 alembic -c development.ini revision --autogenerate -m "test"

我得到以下结果:

Traceback (most recent call last):
  File "/Users/charleswesley/.virtualenvs/foundation/bin/alembic", line 9, in <module>
    load_entry_point('alembic==0.6.1', 'console_scripts', 'alembic')()
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/config.py", line 298, in main
    CommandLine(prog=prog).main(argv=argv)
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/config.py", line 293, in main
    self.run_cmd(cfg, options)
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/config.py", line 279, in run_cmd
    **dict((k, getattr(options, k)) for k in kwarg)
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/command.py", line 97, in revision
    script.run_env()
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/script.py", line 199, in run_env
    util.load_python_file(self.dir, 'env.py')
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/util.py", line 198, in load_python_file
    module = load_module(module_id, path)
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/compat.py", line 49, in load_module
    return machinery.SourceFileLoader(module_id, path).load_module()
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1024, in load_module
  File "<frozen importlib._bootstrap>", line 1005, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 870, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "/Users/charleswesley/repos/foundation/foundation/scripts/alembic/env.py", line 74, in <module>
    run_migrations_online()
  File "/Users/charleswesley/repos/foundation/foundation/scripts/alembic/env.py", line 67, in run_migrations_online
    context.run_migrations()
  File "<string>", line 7, in run_migrations
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/environment.py", line 652, in run_migrations
    self.get_context().run_migrations(**kw)
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/migration.py", line 210, in run_migrations
    self):
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/command.py", line 83, in retrieve_migrations
    autogen._produce_migration_diffs(context, template_args, imports)
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/autogenerate/api.py", line 143, in _produce_migration_diffs
    autogen_context, object_filters, include_schemas)
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/autogenerate/api.py", line 198, in _produce_net_changes
    inspector, metadata, diffs, autogen_context)
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/autogenerate/compare.py", line 32, in _compare_tables
    set())
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/autogenerate/compare.py", line 243, in _compare_indexes
    for i in reflected_indexes
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/autogenerate/compare.py", line 243, in <genexpr>
    for i in reflected_indexes
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/autogenerate/compare.py", line 83, in _make_index
    unique=params['unique']
  File "/Users/charleswesley/.virtualenvs/foundation/lib/python3.3/site-packages/alembic-0.6.1-py3.3.egg/alembic/autogenerate/compare.py", line 82, in <listcomp>
    *[conn_table.c[cname] for cname in params['column_names']],
AttributeError: 'NoneType' object has no attribute 'c'

我真的不确定这里会出现什么问题。我正在尝试使用Postgres 9.2,SQLAlchemy 0.8.4和Alembic 0.6.1。但我在Postgres 9.3,SQLAlchemy 0.9和Alembic 0.6.2中看到了相同的结果。我们正在使用自定义数据库模式,如果这有所不同。

1 个答案:

答案 0 :(得分:2)

使用自定义架构和alembic时,此错误也发生在我身上。 This commit修正了它。