summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJon Dufresne <jon.dufresne@gmail.com>2020-07-06 17:08:25 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-07-20 15:04:22 +0200
commit796be5901a67da44e251e092641682cb2d778176 (patch)
treebc234f48ff316f7335a09b62cf4486ba94aaba47 /django
parent80f92177eb2a175579f4a6907ef5a358863bddca (diff)
Fixed #31769 -- Improved default naming of merged migrations.
47 gives 60 in total (47 + 5 + 5 + 3).
Diffstat (limited to 'django')
-rw-r--r--django/core/management/commands/makemigrations.py15
1 files changed, 11 insertions, 4 deletions
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)