mirror of
https://github.com/django/django.git
synced 2025-10-24 14:16:09 +00:00
Fixed #23916 -- Allowed makemigrations to handle related model name case changes.
Made autodetector ignore related model name case changes so unnecessary migrations are not created.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f3da09df0f
commit
9e1b6b8a66
@@ -1014,7 +1014,7 @@ class AutodetectorTests(TestCase):
|
||||
'renamed_foo',
|
||||
'django.db.models.ForeignKey',
|
||||
[],
|
||||
{'to': 'app.Foo', 'on_delete': models.CASCADE, 'db_column': 'foo_id'},
|
||||
{'to': 'app.foo', 'on_delete': models.CASCADE, 'db_column': 'foo_id'},
|
||||
))
|
||||
|
||||
def test_rename_model(self):
|
||||
@@ -1032,6 +1032,22 @@ class AutodetectorTests(TestCase):
|
||||
# no AlterField for the related field.
|
||||
self.assertNumberMigrations(changes, 'otherapp', 0)
|
||||
|
||||
def test_rename_model_case(self):
|
||||
"""
|
||||
Model name is case-insensitive. Changing case doesn't lead to any
|
||||
autodetected operations.
|
||||
"""
|
||||
author_renamed = ModelState('testapp', 'author', [
|
||||
('id', models.AutoField(primary_key=True)),
|
||||
])
|
||||
changes = self.get_changes(
|
||||
[self.author_empty, self.book],
|
||||
[author_renamed, self.book],
|
||||
questioner=MigrationQuestioner({'ask_rename_model': True}),
|
||||
)
|
||||
self.assertNumberMigrations(changes, 'testapp', 0)
|
||||
self.assertNumberMigrations(changes, 'otherapp', 0)
|
||||
|
||||
def test_rename_m2m_through_model(self):
|
||||
"""
|
||||
Tests autodetection of renamed models that are used in M2M relations as
|
||||
|
||||
Reference in New Issue
Block a user