I'm working on a project that has both older sqlalchemy-migrate-based migrations and newer alembic-based migrations. I'm trying to remove the former. Ripping it out was easy enough but I'm seeing the following failure when I run some tests after doing so:
Traceback (most recent call last):
File "/home/user/myproject/.tox/functional/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 747, in __getattr__
return getattr(self.comparator, key)
AttributeError: 'Comparator' object has no attribute 'alter'
However, I note that when I re-add an import for the migrate (sqlalchemy-migrate) module into any of the remaining alembic migrations, things start working again? Why does the alter method disappar without this module?
The reason for this was that one of the newer alembic migrations was using the
altermethod that sqlalchemy-migrate seems to monkey-patch in. Specifically, I needed to change the following:to:
(I had to do this instead of
op.alter_columnsince that isn't compatible with SQLite).