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:
@@ -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."""
|
||||
|
||||
Reference in New Issue
Block a user