diff options
| author | Markus Holtermann <info@markusholtermann.eu> | 2015-03-31 23:35:48 +0200 |
|---|---|---|
| committer | Markus Holtermann <info@markusholtermann.eu> | 2015-04-01 11:14:55 +0200 |
| commit | 2218f7617e6192a706bf7792db34b034765263e2 (patch) | |
| tree | a9335e50d5fd82d3dbcc276cb7331a143ec982ad /django | |
| parent | 0c7e2833d9b6f0bbd847d9b9b0eb368611425f7c (diff) | |
[1.8.x] Refs #24554 -- Prevented rendering of unused migrations
Thanks Claude Paroz and Tim Graham for the review
Backport of 3e7d9d05ac5efff4e4732c3453c7a8ef502d0ed0 from master
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/migrations/executor.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py index d1da524aeb..7dc0350927 100644 --- a/django/db/migrations/executor.py +++ b/django/db/migrations/executor.py @@ -86,11 +86,20 @@ class MigrationExecutor(object): # models will be recursively reloaded as explained in # `django.db.migrations.state.get_related_models_recursive()`. for migration, _ in full_plan: + if not migrations_to_run: + # We remove every migration whose state was already computed + # from the set below (`migrations_to_run.remove(migration)`). + # If no states for migrations must be computed, we can exit + # this loop. Migrations that occur after the latest migration + # that is about to be applied would only trigger unneeded + # mutate_state() calls. + break do_run = migration in migrations_to_run if do_run: if 'apps' not in state.__dict__: state.apps # Render all real_apps -- performance critical states[migration] = state.clone() + migrations_to_run.remove(migration) # Only preserve the state if the migration is being run later state = migration.mutate_state(state, preserve=do_run) if self.progress_callback: |
