Add support for changing field types in ChangeField.

Review Request #12234 — Created April 8, 2022 and submitted — Latest diff uploaded

Information

Django Evolution
release-2.x

Reviewers

ChangeField now takes a field_type= option, which is used to change
the type of the field. If the database-specific types differ, then this
will go through the new BaseEvolutionOperations.change_column_type()
machinery to change the type of the field and, depending on the
database, any fields referencing it.

This is also supported when generating hinted evolutions. If the differ
sees that the type of a field has changed, it will generate a sample
ChangeField that changes the type and passes in all attributes (not
just those that would otherwise have changed) so that the backend can
generate a complete column definition.

Changes to fields that don't end up actually altering the type (such as
when two fields map to the same type at the database level) are treated
as a standard ChangeField operation, modifying any changed attributes.

Unit tests have been added for all database backends and for several
field type change scenarios.

All unit tests pass on all supported versions of Python, all versions of
Django, and various versions of all supported database backends.

Commits

Files