mirror of https://github.com/django/django.git
This commit is contained in:
parent
551b0f94bf
commit
b1cb923883
|
@ -183,6 +183,9 @@ class Migration:
|
||||||
are not guaranteed to be unique, but put some effort into the fallback
|
are not guaranteed to be unique, but put some effort into the fallback
|
||||||
name to avoid VCS conflicts if possible.
|
name to avoid VCS conflicts if possible.
|
||||||
"""
|
"""
|
||||||
|
if self.initial:
|
||||||
|
return 'initial'
|
||||||
|
|
||||||
name = None
|
name = None
|
||||||
if len(self.operations) == 1:
|
if len(self.operations) == 1:
|
||||||
name = self.operations[0].migration_name_fragment
|
name = self.operations[0].migration_name_fragment
|
||||||
|
@ -192,7 +195,7 @@ class Migration:
|
||||||
):
|
):
|
||||||
name = '_'.join(sorted(o.migration_name_fragment for o in self.operations))
|
name = '_'.join(sorted(o.migration_name_fragment for o in self.operations))
|
||||||
if name is None:
|
if name is None:
|
||||||
name = 'initial' if self.initial else 'auto_%s' % get_migration_name_timestamp()
|
name = 'auto_%s' % get_migration_name_timestamp()
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -600,8 +600,10 @@ class AutodetectorTests(TestCase):
|
||||||
graph.add_dependency("testapp.0002_foobar", ("testapp", "0002_foobar"), ("testapp", "0001_initial"))
|
graph.add_dependency("testapp.0002_foobar", ("testapp", "0002_foobar"), ("testapp", "0001_initial"))
|
||||||
graph.add_dependency("testapp.0002_foobar", ("testapp", "0002_foobar"), ("otherapp", "0001_initial"))
|
graph.add_dependency("testapp.0002_foobar", ("testapp", "0002_foobar"), ("otherapp", "0001_initial"))
|
||||||
# Use project state to make a new migration change set
|
# Use project state to make a new migration change set
|
||||||
before = self.make_project_state([])
|
before = self.make_project_state([self.publisher, self.other_pony])
|
||||||
after = self.make_project_state([self.author_empty, self.other_pony, self.other_stable])
|
after = self.make_project_state([
|
||||||
|
self.author_empty, self.publisher, self.other_pony, self.other_stable,
|
||||||
|
])
|
||||||
autodetector = MigrationAutodetector(before, after)
|
autodetector = MigrationAutodetector(before, after)
|
||||||
changes = autodetector._detect_changes()
|
changes = autodetector._detect_changes()
|
||||||
# Run through arrange_for_graph
|
# Run through arrange_for_graph
|
||||||
|
@ -609,7 +611,7 @@ class AutodetectorTests(TestCase):
|
||||||
# Make sure there's a new name, deps match, etc.
|
# Make sure there's a new name, deps match, etc.
|
||||||
self.assertEqual(changes["testapp"][0].name, "0003_author")
|
self.assertEqual(changes["testapp"][0].name, "0003_author")
|
||||||
self.assertEqual(changes["testapp"][0].dependencies, [("testapp", "0002_foobar")])
|
self.assertEqual(changes["testapp"][0].dependencies, [("testapp", "0002_foobar")])
|
||||||
self.assertEqual(changes["otherapp"][0].name, "0002_pony_stable")
|
self.assertEqual(changes["otherapp"][0].name, '0002_stable')
|
||||||
self.assertEqual(changes["otherapp"][0].dependencies, [("otherapp", "0001_initial")])
|
self.assertEqual(changes["otherapp"][0].dependencies, [("otherapp", "0001_initial")])
|
||||||
|
|
||||||
def test_arrange_for_graph_with_multiple_initial(self):
|
def test_arrange_for_graph_with_multiple_initial(self):
|
||||||
|
@ -2663,7 +2665,7 @@ class MigrationSuggestNameTests(SimpleTestCase):
|
||||||
]
|
]
|
||||||
|
|
||||||
migration = Migration('0001_initial', 'test_app')
|
migration = Migration('0001_initial', 'test_app')
|
||||||
self.assertEqual(migration.suggest_name(), 'animal_person')
|
self.assertEqual(migration.suggest_name(), 'initial')
|
||||||
|
|
||||||
def test_none_name(self):
|
def test_none_name(self):
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
Loading…
Reference in New Issue