summaryrefslogtreecommitdiff
path: root/django/core
diff options
context:
space:
mode:
authorJohn Giannelos <johngiannelos@gmail.com>2015-03-03 00:13:14 +0200
committerTim Graham <timograham@gmail.com>2015-03-16 14:04:37 -0400
commit8758a63ddbbf7a2626bd84d50cfe83b477e8de0a (patch)
tree019381f991f41559269c2375664263be34e85bfa /django/core
parent818182b514d1c6b379130c440689355b4d231d49 (diff)
Fixed #24427 -- Stopped writing migration files in dry run mode when merging.
Also added display of migration to stdout when verbosity=3.
Diffstat (limited to 'django/core')
-rw-r--r--django/core/management/commands/makemigrations.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py
index d90f5b9428..2fe220b622 100644
--- a/django/core/management/commands/makemigrations.py
+++ b/django/core/management/commands/makemigrations.py
@@ -239,7 +239,18 @@ class Command(BaseCommand):
})
new_migration = subclass("%04i_merge" % (biggest_number + 1), app_label)
writer = MigrationWriter(new_migration)
- with open(writer.path, "wb") as fh:
- fh.write(writer.as_string())
- if self.verbosity > 0:
- self.stdout.write("\nCreated new merge migration %s" % writer.path)
+
+ if not self.dry_run:
+ # Write the merge migrations file to the disk
+ with open(writer.path, "wb") as fh:
+ fh.write(writer.as_string())
+ if self.verbosity > 0:
+ self.stdout.write("\nCreated new merge migration %s" % writer.path)
+ elif self.verbosity == 3:
+ # Alternatively, makemigrations --merge --dry-run --verbosity 3
+ # will output the merge migrations to stdout rather than saving
+ # the file to the disk.
+ self.stdout.write(self.style.MIGRATE_HEADING(
+ "Full merge migrations file '%s':" % writer.filename) + "\n"
+ )
+ self.stdout.write("%s\n" % writer.as_string())