I added new model, then run

$ pipenv run alembic revision --autogenerate -m "Add new table 
TRAVIS_ACTIVE_USERS" --depends-on=<previous-revision>

Then I got this:

INFO  [alembic.runtime.migration] Context impl Db2Impl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/sqlalchemy/engine/reflection.py:943:
 SAWarning: index key 'sqlnotapplicable' was not located in columns for table 
‘github_active_users'
  "columns for table '%s'" % (flavor, c, table_name)
Traceback (most recent call last):
  File "/root/.local/share/virtualenvs/butane-c47Aapyx/bin/alembic", line 8, in 
<module>
    sys.exit(main())
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/config.py",
 line 577, in main
    CommandLine(prog=prog).main(argv=argv)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/config.py",
 line 571, in main
    self.run_cmd(cfg, options)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/config.py",
 line 551, in run_cmd
    **dict((k, getattr(options, k, None)) for k in kwarg)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/command.py",
 line 214, in revision
    script_directory.run_env()
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/script/base.py",
 line 489, in run_env
    util.load_python_file(self.dir, "env.py")
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/util/pyfiles.py",
 line 98, in load_python_file
    module = load_module_py(module_id, path)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/util/compat.py",
 line 184, in load_module_py
    spec.loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "butane/warehouse/env.py", line 91, in <module>
    run_migrations_online()
  File "butane/warehouse/env.py", line 85, in run_migrations_online
    context.run_migrations()
  File "<string>", line 8, in run_migrations
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/runtime/environment.py",
 line 846, in run_migrations
    self.get_context().run_migrations(**kw)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/runtime/migration.py",
 line 509, in run_migrations
    for step in self._migrations_fn(heads, self):
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/command.py",
 line 190, in retrieve_migrations
    revision_context.run_autogenerate(rev, context)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/api.py",
 line 442, in run_autogenerate
    self._run_environment(rev, migration_context, True)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/api.py",
 line 482, in _run_environment
    autogen_context, migration_script
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
 line 25, in _populate_migration_script
    _produce_net_changes(autogen_context, upgrade_ops)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
 line 51, in _produce_net_changes
    autogen_context, upgrade_ops, schemas
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/util/langhelpers.py",
 line 303, in go
    fn(*arg, **kw)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
 line 83, in _autogen_for_tables
    autogen_context,
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
 line 170, in _compare_tables
    autogen_context, modify_table_ops, s, tname, t, None
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/util/langhelpers.py",
 line 303, in go
    fn(*arg, **kw)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
 line 493, in _compare_indexes_and_uniques
    conn_indexes = set(_make_index(ix, conn_table) for ix in conn_indexes)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
 line 493, in <genexpr>
    conn_indexes = set(_make_index(ix, conn_table) for ix in conn_indexes)
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
 line 235, in _make_index
    *[conn_table.c[cname] for cname in params["column_names"]],
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/alembic/autogenerate/compare.py",
 line 235, in <listcomp>
    *[conn_table.c[cname] for cname in params["column_names"]],
  File 
"/root/.local/share/virtualenvs/butane-c47Aapyx/lib/python3.7/site-packages/sqlalchemy/util/_collections.py",
 line 194, in __getitem__
    return self._data[key]
KeyError: ‘sqlnotapplicable'

I got the impression that a new model should NOT depend on existing revision 
but no idea why new revision generation failed.

Notice that I used this code in previous model to avoid generating unwanted 
primary key:

__mapper_args__ = {
        'primary_key': [email, dt_month]
    }


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy-alembic" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy-alembic+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy-alembic/9732B51A-98F0-46C5-85AE-1C80AD53EB5F%40us.ibm.com.

Reply via email to