Opened 7 years ago

Last modified 4 years ago

#27666 closed Cleanup/optimization

Delay rendering of models in migration operations when possible — at Version 3

Reported by: Markus Holtermann Owned by: Markus Holtermann
Component: Migrations Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Markus Holtermann)

As it turns out, when we delay the rendering of related models up to the point where it's necessary (just before RunPython, afaict), we can cut down migration time to a quarter and maybe more: https://github.com/MarkusH/django/commit/6b8280e0582d778944585e966404252c4994185e#commitcomment-19719252

PR: https://github.com/django/django/pull/7589

Given that 3rd party migration operations may need to enforce model rendering like we do for RunPython, we probably need to treat this as a backwards incompatible change, I suppose.

    def database_forwards(self, app_label, schema_editor, from_state, to_state):
        if from_state.is_delayed and 'apps' in from_state.__dict__:
            del from_state.__dict__['apps']
        # ...

Change History (3)

comment:1 by Markus Holtermann, 7 years ago

Owner: changed from nobody to Markus Holtermann
Status: newassigned

comment:2 by Markus Holtermann, 7 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Markus Holtermann, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top