diff options
Diffstat (limited to 'django/core')
| -rw-r--r-- | django/core/management/commands/makemigrations.py | 9 | ||||
| -rw-r--r-- | django/core/management/commands/squashmigrations.py | 7 |
2 files changed, 13 insertions, 3 deletions
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py index cdccb8e9b3..5782b58398 100644 --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -49,6 +49,10 @@ class Command(BaseCommand): help="Use this name for migration file(s).", ) parser.add_argument( + '--no-header', action='store_false', dest='include_header', + help='Do not add header comments to new migration file(s).', + ) + parser.add_argument( '--check', action='store_true', dest='check_changes', help='Exit with a non-zero status if model changes are missing migrations.', ) @@ -63,6 +67,7 @@ class Command(BaseCommand): self.migration_name = options['name'] if self.migration_name and not self.migration_name.isidentifier(): raise CommandError('The migration name must be a valid Python identifier.') + self.include_header = options['include_header'] check_changes = options['check_changes'] # Make sure the app they asked for exists @@ -188,7 +193,7 @@ class Command(BaseCommand): self.stdout.write(self.style.MIGRATE_HEADING("Migrations for '%s':" % app_label) + "\n") for migration in app_migrations: # Describe the migration - writer = MigrationWriter(migration) + writer = MigrationWriter(migration, self.include_header) if self.verbosity >= 1: # Display a relative path if it's below the current working # directory, or an absolute path otherwise. @@ -288,7 +293,7 @@ class Command(BaseCommand): self.migration_name or ("merge_%s" % get_migration_name_timestamp()) ) new_migration = subclass(migration_name, app_label) - writer = MigrationWriter(new_migration) + writer = MigrationWriter(new_migration, self.include_header) if not self.dry_run: # Write the merge migrations file to the disk diff --git a/django/core/management/commands/squashmigrations.py b/django/core/management/commands/squashmigrations.py index ee91241369..4a0ab6af83 100644 --- a/django/core/management/commands/squashmigrations.py +++ b/django/core/management/commands/squashmigrations.py @@ -37,6 +37,10 @@ class Command(BaseCommand): '--squashed-name', help='Sets the name of the new squashed migration.', ) + parser.add_argument( + '--no-header', action='store_false', dest='include_header', + help='Do not add a header comment to the new squashed migration.', + ) def handle(self, **options): @@ -47,6 +51,7 @@ class Command(BaseCommand): migration_name = options['migration_name'] no_optimize = options['no_optimize'] squashed_name = options['squashed_name'] + include_header = options['include_header'] # Validate app_label. try: apps.get_app_config(app_label) @@ -178,7 +183,7 @@ class Command(BaseCommand): new_migration.initial = True # Write out the new migration file - writer = MigrationWriter(new_migration) + writer = MigrationWriter(new_migration, include_header) with open(writer.path, "w", encoding='utf-8') as fh: fh.write(writer.as_string()) |
