diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py index d5ad3304e129f..2d1551482171a 100644 --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -58,8 +58,8 @@ def add_arguments(self, parser): help='Exit with a non-zero status if model changes are missing migrations.', ) parser.add_argument( - '--structured', action='store_true', dest='structured_output', - help='Output only created migration filepaths to stdout; all other logging to stderr.', + '--separatelogs', action='store_true', dest='separate_logs', + help='Output only created migration filepaths to stdout; divert other logging to stderr.', ) @no_translations @@ -74,8 +74,8 @@ def handle(self, *app_labels, **options): raise CommandError('The migration name must be a valid Python identifier.') self.include_header = options['include_header'] check_changes = options['check_changes'] - self.structured_output = options['structured_output'] - if self.structured_output: + self.separate_logs = options['separate_logs'] + if self.separate_logs: self.log = self.stderr else: self.log = self.stdout @@ -224,7 +224,7 @@ def write_migration_files(self, changes): self.log.write(' %s\n' % self.style.MIGRATE_LABEL(migration_string)) for operation in migration.operations: self.log.write(' - %s' % operation.describe()) - if self.structured_output: + if self.separate_logs: self.stdout.write(migration_string + '\n') if not self.dry_run: # Write the migrations file to the disk. diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index bc73cad0c2a01..545c2e252c34d 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -837,10 +837,10 @@ migrations are detected. connection was added. In that case, check for a consistent migration history is skipped. -.. django-admin-option:: --structured +.. django-admin-option:: --separatelogs -Diverts log output of ``makemigrations`` to stderr and writes only paths of -generated migration files to stdout. +Diverts log output of ``makemigrations`` to ``stderr`` and writes only paths +of generated migration files to ``stdout``. .. versionadded:: 4.0 diff --git a/docs/releases/4.0.txt b/docs/releases/4.0.txt index b4e194f10280b..1a15d42fa2e5b 100644 --- a/docs/releases/4.0.txt +++ b/docs/releases/4.0.txt @@ -269,9 +269,9 @@ Management Commands As a consequence, ``readline`` is no longer loaded if running in *isolated* mode. -* :djadmin:`makemigrations` can now be called with ``--structured`` to divert - logging to stderr and produce only structured output to stdout consisting - of the paths of generated migration files. +* The :djadmin:`makemigrations` command can now be called with + :option:`--separatelogs` to divert logging to `stderr` and write only the + paths of generated migration files to stdout. Migrations ~~~~~~~~~~ diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py index 9aed195d0041f..1d0d669869045 100644 --- a/tests/migrations/test_commands.py +++ b/tests/migrations/test_commands.py @@ -1528,10 +1528,10 @@ class Meta: self.assertIn("model_name='sillymodel',", out.getvalue()) self.assertIn("name='silly_char',", out.getvalue()) - def test_makemigrations_structured_output(self): + def test_makemigrations_separate_logs(self): """ - With structured=True, logging is diverted to self.stderr, and only the paths - of generated migration files are written to self.stdout. + With separatelogs=True, logging is diverted to stderr, and only the + paths of generated migration files are written to stdout. """ class SillyModel(models.Model): silly_field = models.BooleanField(default=False) @@ -1543,7 +1543,7 @@ class Meta: out = io.StringIO() err = io.StringIO() with self.temporary_migration_module(module='migrations.migrations'): - call_command('makemigrations', 'migrations', structured=True, stdout=out, stderr=err) + call_command('makemigrations', 'migrations', separatelogs=True, stdout=out, stderr=err) self.assertIn('/migrations/0001_initial.py\n', out.getvalue()) self.assertIn(' - Create model ModelWithCustomBase\n', err.getvalue()) self.assertNotIn(' - Create model ModelWithCustomBase\n', out.getvalue())