mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Refs #27064 -- Made migrations generate RenameIndex operations when renaming Meta.indexes.
This commit is contained in:
committed by
Mariusz Felisiak
parent
11310e9abb
commit
c6cec3c2d2
@@ -2565,6 +2565,39 @@ class AutodetectorTests(TestCase):
|
||||
changes, "otherapp", 0, 0, model_name="book", name="book_title_author_idx"
|
||||
)
|
||||
|
||||
def test_rename_indexes(self):
|
||||
book_renamed_indexes = ModelState(
|
||||
"otherapp",
|
||||
"Book",
|
||||
[
|
||||
("id", models.AutoField(primary_key=True)),
|
||||
("author", models.ForeignKey("testapp.Author", models.CASCADE)),
|
||||
("title", models.CharField(max_length=200)),
|
||||
],
|
||||
{
|
||||
"indexes": [
|
||||
models.Index(
|
||||
fields=["author", "title"], name="renamed_book_title_author_idx"
|
||||
)
|
||||
],
|
||||
},
|
||||
)
|
||||
changes = self.get_changes(
|
||||
[self.author_empty, self.book_indexes],
|
||||
[self.author_empty, book_renamed_indexes],
|
||||
)
|
||||
self.assertNumberMigrations(changes, "otherapp", 1)
|
||||
self.assertOperationTypes(changes, "otherapp", 0, ["RenameIndex"])
|
||||
self.assertOperationAttributes(
|
||||
changes,
|
||||
"otherapp",
|
||||
0,
|
||||
0,
|
||||
model_name="book",
|
||||
new_name="renamed_book_title_author_idx",
|
||||
old_name="book_title_author_idx",
|
||||
)
|
||||
|
||||
def test_order_fields_indexes(self):
|
||||
"""Test change detection of reordering of fields in indexes."""
|
||||
changes = self.get_changes(
|
||||
|
||||
Reference in New Issue
Block a user