diff options
| author | Moayad Mardini <moayad.m@gmail.com> | 2014-05-26 23:09:17 +0300 |
|---|---|---|
| committer | Moayad Mardini <moayad.m@gmail.com> | 2014-05-27 00:40:55 +0300 |
| commit | 2e613ea5c52d4d12e071987178af18c0371d6e2f (patch) | |
| tree | 830aa0eef0d7e5c5462bf7ab43aeff43eb9b60e6 /django | |
| parent | b625e861e5d2709a16588ecb82f46e1fb86004c7 (diff) | |
Fixed #22675 -- makemigrations --dry-run to output migrations to stdout.
`makemigrations --dry-run` will output the complete migrations file
that would be written if it's used along with `--verbosity 3`.
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/commands/makemigrations.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py index 97661ea8b5..839592a22a 100644 --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -123,8 +123,8 @@ class Command(BaseCommand): self.stdout.write(" %s:\n" % (self.style.MIGRATE_LABEL(writer.filename),)) for operation in migration.operations: self.stdout.write(" - %s\n" % operation.describe()) - # Write it if not self.dry_run: + # Write the migrations file to the disk. migrations_directory = os.path.dirname(writer.path) if not directory_created.get(app_label, False): if not os.path.isdir(migrations_directory): @@ -137,6 +137,12 @@ class Command(BaseCommand): migration_string = writer.as_string() with open(writer.path, "wb") as fh: fh.write(migration_string) + elif self.verbosity == 3: + # Alternatively, makemigrations --dry-run --verbosity 3 + # will output the migrations to stdout rather than saving + # the file to the disk. + self.stdout.write(self.style.MIGRATE_HEADING("Full migrations file '%s':" % writer.filename) + "\n") + self.stdout.write("%s\n" % writer.as_string()) def handle_merge(self, loader, conflicts): """ |
