diff options
| author | Tillmann Karras <tilkax@gmail.com> | 2014-11-16 18:42:23 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-11-18 07:37:06 +0100 |
| commit | d18810131995dac63f9d89b0beaeadfc935130aa (patch) | |
| tree | 7c6215c8e7f41b366310de9b54a4cdb0646be304 /django | |
| parent | dee3946a91be2c880b5930550db681aae54b19ed (diff) | |
Fixed #23799 -- Made makemigrations respect --no-optimize.
Thanks to yamila-moreno for the idea of a skip message.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/commands/squashmigrations.py | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/django/core/management/commands/squashmigrations.py b/django/core/management/commands/squashmigrations.py index 9cd9915574..6f598757b6 100644 --- a/django/core/management/commands/squashmigrations.py +++ b/django/core/management/commands/squashmigrations.py @@ -26,7 +26,9 @@ class Command(BaseCommand): self.verbosity = options.get('verbosity') self.interactive = options.get('interactive') - app_label, migration_name = options['app_label'], options['migration_name'] + app_label = options['app_label'] + migration_name = options['migration_name'] + no_optimize = options['no_optimize'] # Load the current graph state, check the app and migration they asked for exists executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) @@ -95,20 +97,25 @@ class Command(BaseCommand): elif dependency[0] != smigration.app_label: dependencies.add(dependency) - if self.verbosity > 0: - self.stdout.write(self.style.MIGRATE_HEADING("Optimizing...")) + if no_optimize: + if self.verbosity > 0: + self.stdout.write(self.style.MIGRATE_HEADING("(Skipping optimization.)")) + new_operations = operations + else: + if self.verbosity > 0: + self.stdout.write(self.style.MIGRATE_HEADING("Optimizing...")) - optimizer = MigrationOptimizer() - new_operations = optimizer.optimize(operations, migration.app_label) + optimizer = MigrationOptimizer() + new_operations = optimizer.optimize(operations, migration.app_label) - if self.verbosity > 0: - if len(new_operations) == len(operations): - self.stdout.write(" No optimizations possible.") - else: - self.stdout.write( - " Optimized from %s operations to %s operations." % - (len(operations), len(new_operations)) - ) + if self.verbosity > 0: + if len(new_operations) == len(operations): + self.stdout.write(" No optimizations possible.") + else: + self.stdout.write( + " Optimized from %s operations to %s operations." % + (len(operations), len(new_operations)) + ) # Work out the value of replaces (any squashed ones we're re-squashing) # need to feed their replaces into ours |
