From cee95e6172f2ea3dbf8cfd4214562cfc92f95392 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Thu, 29 Aug 2024 18:52:31 +0100 Subject: Fixed #35717 -- Reduced Create/RemoveCollation operations when optimizing migrations. --- django/contrib/postgres/operations.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'django') diff --git a/django/contrib/postgres/operations.py b/django/contrib/postgres/operations.py index 1ee5fbc2e2..84360febf9 100644 --- a/django/contrib/postgres/operations.py +++ b/django/contrib/postgres/operations.py @@ -237,6 +237,11 @@ class CreateCollation(CollationOperation): def migration_name_fragment(self): return "create_collation_%s" % self.name.lower() + def reduce(self, operation, app_label): + if isinstance(operation, RemoveCollation) and self.name == operation.name: + return [] + return super().reduce(operation, app_label) + class RemoveCollation(CollationOperation): """Remove a collation.""" -- cgit v1.3