Defer constraints and indexes when creating models through the evolver.

Review Request #12282 — Created May 16, 2022 and submitted

Information

Django Evolution
release-2.x

Reviewers

When generating SQL for new models, EvolveAppTask was lumping together
the SQL for the model creation and for any constraints/indexes. This
could be fine a lot of the time, but depending on the complexity of the
upgrade, that deferred SQL could fail.

A sample scenario would be an app creating a model that has a reference
to an existing model, but to a newer Primary Key type that would be (but
hasn't yet been) evolved on the target model.

We now separately track the model creation SQL and the deferred SQL. All
deferred SQL is executed once all evolutions and migrations have
concluded.

All unit tests pass for all databases.

Verified this fixed a messy upgrade issue with Review Board 4 -> 5.

Summary ID
Defer constraints and indexes when creating models through the evolver.
When generating SQL for new models, `EvolveAppTask` was lumping together the SQL for the model creation and for any constraints/indexes. This could be fine a lot of the time, but depending on the complexity of the upgrade, that deferred SQL could fail. A sample scenario would be an app creating a model that has a reference to an existing model, but to a newer Primary Key type that would be (but hasn't yet been) evolved on the target model. We now separately track the model creation SQL and the deferred SQL. All deferred SQL is executed once all evolutions and migrations have concluded.
fd87cf874ff4490953df00b46ee8a94b4cb7ad2e
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-2.x (52c43f8)
Loading...