Don't attempt to apply mutations to newly-added models.

Review Request #11887 — Created Dec. 16, 2021 and submitted

Information

Django Evolution
release-2.x

Reviewers

When calculating the mutations that are relevant to a model, any models
found in the new signature are compared to the old signature, and if
their signatures match, the model is discarded from the list of models
that mutations may apply to.

This assumed if the model wasn't present in the old signature, it would
be considered changed. It also assumed that any new models would have a
baseline present in the signature. That was a valid assumption back when
evolution was somewhat driven by syncdb/migrate signals, but Evolver
changes that a bit. It's now possible for a model to not be in the old
signature at the time this computation is occurring.

Models not present in the old signature are now skipped, with the
assumption being that the baseline with all evolutions will be installed
in a later step. This prevents evolutions from incorrectly applying
immediately after a model is installed.

Unit tests pass on all supported versions of Django and Python.

Tested with a customer in production that was hitting an issue when
upgrading from a very old release of Review Board.

Summary ID
Don't attempt to apply mutations to newly-added models.
When calculating the mutations that are relevant to a model, any models found in the new signature are compared to the old signature, and if their signatures match, the model is discarded from the list of models that mutations may apply to. This assumed if the model wasn't present in the old signature, it would be considered changed. It also assumed that any new models would have a baseline present in the signature. That was a valid assumption back when evolution was somewhat driven by syncdb/migrate signals, but `Evolver` changes that a bit. It's now possible for a model to not be in the old signature at the time this computation is occurring. Models not present in the old signature are now skipped, with the assumption being that the baseline with all evolutions will be installed in a later step. This prevents evolutions from incorrectly applying immediately after a model is installed.
d47d93972746f2bfa73f51df2ccfda66c37aa46f
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-2.x (56d6831)