Every time I update my models I have to delete and reinitialize the database.
./manage.py db init
and then initial
./manage.py db migrate
work but every subsequent ./manage.py db migrate
fails with the following error:
INFO [alembic.migration] Context impl SQLiteImpl.
INFO [alembic.migration] Will assume non-transactional DDL.
Traceback (most recent call last):
File "manage.py", line 110, in <module>
manager.run()
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages
/flask_script/__init__.py", line 405, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages
/flask_script/__init__.py", line 384, in handle
return handle(app, *positional_args, **kwargs)
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages
/flask_script/commands.py", line 145, in handle
return self.run(*args, **kwargs)
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages
/flask_migrate/__init__.py", line 80, in migrate
command.revision(config, message, autogenerate = True, sql = sql)
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages /alembic/command.py", line 97, in revision
script.run_env()
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages /alembic/script.py", line 199, in run_env
util.load_python_file(self.dir, 'env.py')
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages/alembic/util.py", line 199, in load_python_file
module = load_module(module_id, path)
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages/alembic/compat.py", line 49, in load_module
return machinery.SourceFileLoader(module_id, path).load_module()
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 "migrations/env.py", line 72, in <module>
run_migrations_online()
File "migrations/env.py", line 65, in run_migrations_online
context.run_migrations()
File "<string>", line 7, in run_migrations
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages/alembic/environment.py", line 652, in run_migrations
self.get_context().run_migrations(**kw)
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages /alembic/migration.py", line 210, in run_migrations
self):
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages/alembic/command.py", line 83, in retrieve_migrations
autogen._produce_migration_diffs(context, template_args, imports)
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages/alembic/autogenerate/api.py", line 143, in _produce_migration_diffs
autogen_context, object_filters, include_schemas)
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages/alembic/autogenerate/api.py", line 198, in _produce_net_changes
inspector, metadata, diffs, autogen_context)
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages/alembic/autogenerate/compare.py", line 69, in _compare_tables
diffs, autogen_context, inspector)
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages/alembic/autogenerate/compare.py", line 223, in _compare_indexes_and_uniques
metadata_indexes
File "/home/sergi/.virtualenvs/flaskvenv/lib/python3.4/site-packages/alembic/ddl/sqlite.py", line 56, in correct_for_autogen_constraints
conn_uniques.remove(idx)
NameError: name 'conn_uniques' is not defined
I use the SQLite3 database. I had my models split into several files but put them in a single file but no help. I also tried upgrading flask-migrate
, flask-sqlalchemy
and other packages but also no help. What could be wrong?
Update: I am using the Alembic version 0.6.2
It's really odd, but a few of the 0.6.x releases of Alembic appear to have this undefined symbol.
The mistake was corrected in release 0.6.7. Here is the commit that shows how this line was corrected: https://github.com/zzzeek/alembic/commit/ead05ce48d40d4235b2395972fd1a6efb96d414c
Pretty sure if you upgrade to 0.6.7 or newer the problem will be resolved.