Revert "Fixes #21747: Skip search caching when encountering an invalid schema during migrations (#21748)" (#21787)

This reverts commit 296b89ae02.
This commit is contained in:
Jeremy Stretch
2026-03-30 17:31:41 -04:00
committed by GitHub
parent e54ed87863
commit 5ab9608e38

View File

@@ -1,11 +1,9 @@
import logging
from collections import defaultdict from collections import defaultdict
import netaddr import netaddr
from django.conf import settings from django.conf import settings
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ImproperlyConfigured from django.core.exceptions import ImproperlyConfigured
from django.db import ProgrammingError
from django.db.models import F, Q, Window, prefetch_related_objects from django.db.models import F, Q, Window, prefetch_related_objects
from django.db.models.fields.related import ForeignKey from django.db.models.fields.related import ForeignKey
from django.db.models.functions import window from django.db.models.functions import window
@@ -26,8 +24,6 @@ from . import FieldTypes, LookupTypes, get_indexer
DEFAULT_LOOKUP_TYPE = LookupTypes.PARTIAL DEFAULT_LOOKUP_TYPE = LookupTypes.PARTIAL
MAX_RESULTS = 1000 MAX_RESULTS = 1000
logger = logging.getLogger(__name__)
class SearchBackend: class SearchBackend:
""" """
@@ -67,12 +63,7 @@ class SearchBackend:
""" """
Receiver for the post_save signal, responsible for caching object creation/changes. Receiver for the post_save signal, responsible for caching object creation/changes.
""" """
try: self.cache(instance, remove_existing=not created)
self.cache(instance, remove_existing=not created)
except ProgrammingError as e:
# The schema may be incomplete during migrations; skip caching.
logger.warning(f"Skipping search cache update due to schema error: {e}")
pass
def removal_handler(self, sender, instance, **kwargs): def removal_handler(self, sender, instance, **kwargs):
""" """