diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-05-01 18:57:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 18:57:24 +0200 |
commit | 191f6a9a4586b5e5f79f4f42f190e7ad4bbacc84 (patch) | |
tree | b141c7516dd1bf2fab4d732aeaaafde20e0a40bb /django | |
parent | 0b0998dc151feb77068e2387c34cc50ef6b356ae (diff) | |
download | django-191f6a9a4586b5e5f79f4f42f190e7ad4bbacc84.tar.gz |
Fixed #34528 -- Reduced Add/RemoveIndex operations when optimizing migrations.
Diffstat (limited to 'django')
-rw-r--r-- | django/db/migrations/operations/models.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py index 967a91fdc8..b89b6b511b 100644 --- a/django/db/migrations/operations/models.py +++ b/django/db/migrations/operations/models.py @@ -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.""" |