mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #28051 -- Made migrations respect Index's name argument.
Thanks Marc Tamlyn for the report and Tim Graham for the review.
This commit is contained in:
parent
5d3b322dce
commit
d3cf75ec6f
3 changed files with 18 additions and 2 deletions
|
@ -1070,6 +1070,19 @@ class ModelStateTests(SimpleTestCase):
|
|||
child1_state.options['indexes'][0].name = 'bar'
|
||||
self.assertEqual(Child1._meta.indexes[0].name, 'migrations__name_b0afd7_idx')
|
||||
|
||||
@isolate_apps('migrations')
|
||||
def test_explicit_index_name(self):
|
||||
class TestModel(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
|
||||
class Meta:
|
||||
app_label = 'migrations'
|
||||
indexes = [models.indexes.Index(fields=['name'], name='foo_idx')]
|
||||
|
||||
model_state = ModelState.from_model(TestModel)
|
||||
index_names = [index.name for index in model_state.options['indexes']]
|
||||
self.assertEqual(index_names, ['foo_idx'])
|
||||
|
||||
|
||||
class RelatedModelsTests(SimpleTestCase):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue