Opened 9 years ago

Closed 9 years ago

#26710 closed Cleanup/optimization (fixed)

CreateModel.references_model should take app_label into account

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

CreateModel.references_model doesn't take app_label into account, this blocks some optimizations. For example:

MigrationOptimizer().optimize(
    [
        migrations.CreateModel("Foo", [("name", models.CharField(max_length=255))]),
        migrations.CreateModel("Bar", [("other", models.ForeignKey("testapp.Foo", models.CASCADE))]),
        migrations.DeleteModel("Foo"),
    ],
    app_label="otherapp"
)

returns same operations, though creation and deletion of Foo could be collapsed, because this model is not referenced by Bar.

Change History (5)

comment:1 by Sergey Fedoseev, 9 years ago

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 by Sergey Fedoseev, 9 years ago

Has patch: set

comment:3 by Simon Charette, 9 years ago

Patch needs improvement: set
Triage Stage: UnreviewedAccepted

comment:4 by Simon Charette, 9 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:5 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: assignedclosed

In 7fc4c1d:

Fixed #26710 -- Made CreateModel.references_model() take app_label into account.

Note: See TracTickets for help on using tickets.
Back to Top