Add field type change support in each database backend.

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

Information

Django Evolution
release-2.x

Reviewers

This updates the MySQL, Postgres, and SQLite database backends to
support changing the types of a field.

Both MySQL and Postgres build upon the common code, building SQL for
altering the field type, and letting the common code handle constraint
management. This is more complicated in the case of Postgres, where we
also need to backup/restore the AUTO INCREMENT state, and need to
cast field types. MySQL does not appear to require either of these
operations.

The SQLite support, as per usual, requires a full table rebuild in order
to change columns. This completely overrides the common code, going
through our standard table rebuild logic. There isn't much that's needed
here, since we already have machinery set up for determining how to
replace an existing field, and the type isn't really special in this
regard. The only addition to the logic is a new CHANGE COLUMN TYPE
operator that's passed in order to set the right field state.

Upcoming changes will introduce ChangeField support for invoking this
behavior, along with unit tests.

Unit tests pass when used with the other in-progress changes.

Commits

Files