From 796be5901a67da44e251e092641682cb2d778176 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Mon, 6 Jul 2020 17:08:25 -0700 Subject: Fixed #31769 -- Improved default naming of merged migrations. 47 gives 60 in total (47 + 5 + 5 + 3). --- django/core/management/commands/makemigrations.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'django') diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py index c8c688ec94..5c0a7829b4 100644 --- a/django/core/management/commands/makemigrations.py +++ b/django/core/management/commands/makemigrations.py @@ -295,10 +295,17 @@ class Command(BaseCommand): subclass = type("Migration", (Migration,), { "dependencies": [(app_label, migration.name) for migration in merge_migrations], }) - migration_name = "%04i_%s" % ( - biggest_number + 1, - self.migration_name or ("merge_%s" % get_migration_name_timestamp()) - ) + parts = ['%04i' % (biggest_number + 1)] + if self.migration_name: + parts.append(self.migration_name) + else: + parts.append('merge') + leaf_names = '_'.join(sorted(migration.name for migration in merge_migrations)) + if len(leaf_names) > 47: + parts.append(get_migration_name_timestamp()) + else: + parts.append(leaf_names) + migration_name = '_'.join(parts) new_migration = subclass(migration_name, app_label) writer = MigrationWriter(new_migration, self.include_header) -- cgit v1.3