Migrated issue, originally created by frol (@frol)
Having a custom column type, e.g.:
class PasswordType(types.TypeDecorator, ScalarCoercible): def load_dialect_impl(self, dialect): if dialect.name == 'sqlite': # Use a NUMERIC type for sqlite impl = sqlite.NUMERIC(self.length) else: # Use a VARBINARY for all other dialects. impl = types.VARBINARY(self.length) return dialect.type_descriptor(impl)
Alembic crashes when tries to compare the existing (the first migration is fine) column with the custom type:
File ".../lib/python3.5/site-packages/alembic/autogenerate/compare.py", line 77, in _autogen_for_tables
inspector, metadata, upgrade_ops, autogen_context)
File ".../lib/python3.5/site-packages/alembic/autogenerate/compare.py", line 177, in _compare_tables
modify_table_ops, autogen_context, inspector):
File ".../lib/python3.5/contextlib.py", line 59, in __enter__
return next(self.gen)
File ".../lib/python3.5/site-packages/alembic/autogenerate/compare.py", line 256, in _compare_columns
schema, tname, colname, conn_col, metadata_col
File ".../lib/python3.5/site-packages/alembic/util/langhelpers.py", line 314, in go
fn(*arg, **kw)
File ".../lib/python3.5/site-packages/alembic/autogenerate/compare.py", line 624, in _compare_type
conn_col, metadata_col)
File ".../lib/python3.5/site-packages/alembic/runtime/migration.py", line 391, in _compare_type
metadata_column)
File ".../lib/python3.5/site-packages/alembic/ddl/impl.py", line 261, in compare_type
return comparator and comparator(metadata_type, conn_type)
File ".../lib/python3.5/site-packages/alembic/ddl/impl.py", line 335, in _numeric_compare
t1.precision is not None and
File ".../lib/python3.5/site-packages/sqlalchemy/sql/type_api.py", line 913, in __getattr__
return getattr(self.impl, key)
AttributeError: 'VARBINARY' object has no attribute 'precision'
I have attempted to fix this in PR: https://bitbucket.org/zzzeek/alembic/pull-requests/64/