Changes between Initial Version and Version 1 of Ticket #33586, comment 16


Ignore:
Timestamp:
Sep 24, 2022, 12:59:51 AM (20 months ago)
Author:
Bhuvnesh

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #33586, comment 16

    initial v1  
    77}}}
    88
    9 one thing we can do is re-creating the apps inside {{{database_backwards}}} for RunPython Operation. This should also not affect the performance much.
     9one thing we can do is clear apps cache inside {{{database_backwards}}} for RunPython Operation. This should also not affect the performance much.
    1010{{{ #!patch
    1111diff --git a/django/db/migrations/operations/special.py b/django/db/migrations/operations/special.py
    12 index 94a6ec72de..835f2c7017 100644
     12index 94a6ec72de..6acdfb6cb3 100644
    1313--- a/django/db/migrations/operations/special.py
    1414+++ b/django/db/migrations/operations/special.py
     
    1717 
    1818     def database_backwards(self, app_label, schema_editor, from_state, to_state):
    19 +        from_state.__dict__.pop('apps', None)
     19+        from_state.clear_delayed_apps_cache()
    2020         if self.reverse_code is None:
    2121             raise NotImplementedError("You cannot reverse this operation")
    2222         if router.allow_migrate(
     23
    2324}}}
    24 we could've done the same thing inside {{{RunPython.state_forwards}}} but since reloading apps is not required for forward migrations, we can save some time there.
     25
    2526
    2627Ps: Passing all tests.
Back to Top