alembic icon indicating copy to clipboard operation
alembic copied to clipboard

implement compare_against_backend for SQLAlchemy

Open johaven opened this issue 6 years ago • 3 comments

I have to change this:

email = db.Column(db.String(255))

to

email = db.Column(db.Text)

but nothing is detected during migration (with compare_type=True).

The only way to detect this case is to set a length to the email field like this:

email = db.Column(db.Text(length=16777215)

johaven avatar Jul 03 '19 09:07 johaven

hi there -

this depends highly on the kind of database you are using, may I please know what it is?

zzzeek avatar Jul 03 '19 13:07 zzzeek

mysql/mariadb

johaven avatar Jul 03 '19 13:07 johaven

there is currently no type comparison that is more fine grained than the so-called "type affinity" of a datatype, such as Numeric vs. String. Detailed comparison of types, such as to detect that String() on MySQL renders VARCHAR which is not the same as TEXT, as well as that String(50) has a different length than String(100), needs to happen within the type objects and usually on a per-dialect level on the SQLAlchemy side and there is no timeline for this to be implemented.

zzzeek avatar Jul 03 '19 14:07 zzzeek