Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Better default name for migrations we can't give nice names to

  • Loading branch information...
1 parent 248fdb1 commit cee4fe73071b469edf118bec3a080ffca906d323 @andrewgodwin andrewgodwin committed
Showing with 5 additions and 3 deletions.
  1. +5 −3 django/db/migrations/
8 django/db/migrations/
@@ -1,4 +1,5 @@
import re
+import datetime
from django.db.migrations import operations
from django.db.migrations.migration import Migration
@@ -350,8 +351,9 @@ def _trim_to_apps(self, changes, app_labels):
def suggest_name(cls, ops):
Given a set of operations, suggests a name for the migration
- they might represent. Names not guaranteed to be unique; they
- must be prefixed by a number or date.
+ they might represent. Names are not guaranteed to be unique,
+ but we put some effort in to the fallback name to avoid VCS conflicts
+ if we can.
if len(ops) == 1:
if isinstance(ops[0], operations.CreateModel):
@@ -364,7 +366,7 @@ def suggest_name(cls, ops):
return "remove_%s_%s" % (ops[0].model_name.lower(), ops[0].name.lower())
elif all(isinstance(o, operations.CreateModel) for o in ops):
return "_".join(sorted( for o in ops))
- return "auto"
+ return "auto_%s" %"%Y%m%d_%H%M")
def parse_number(cls, name):

0 comments on commit cee4fe7

Please sign in to comment.
Something went wrong with that request. Please try again.