1
0
mirror of https://github.com/django/django.git synced 2025-10-25 14:46:09 +00:00

Fixed #34528 -- Reduced Add/RemoveIndex operations when optimizing migrations.

This commit is contained in:
Mariusz Felisiak
2023-05-01 18:57:24 +02:00
committed by GitHub
parent 0b0998dc15
commit 191f6a9a45
2 changed files with 19 additions and 0 deletions

View File

@@ -861,6 +861,11 @@ class AddIndex(IndexOperation):
def migration_name_fragment(self):
return "%s_%s" % (self.model_name_lower, self.index.name.lower())
def reduce(self, operation, app_label):
if isinstance(operation, RemoveIndex) and self.index.name == operation.name:
return []
return super().reduce(operation, app_label)
class RemoveIndex(IndexOperation):
"""Remove an index from a model."""