mirror of
https://github.com/netbox-community/netbox.git
synced 2026-03-27 11:51:50 +01:00
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
|
||||
import netaddr
|
||||
from django.conf import settings
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
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.fields.related import ForeignKey
|
||||
from django.db.models.functions import window
|
||||
@@ -24,6 +26,8 @@ from . import FieldTypes, LookupTypes, get_indexer
|
||||
DEFAULT_LOOKUP_TYPE = LookupTypes.PARTIAL
|
||||
MAX_RESULTS = 1000
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SearchBackend:
|
||||
"""
|
||||
@@ -63,7 +67,12 @@ class SearchBackend:
|
||||
"""
|
||||
Receiver for the post_save signal, responsible for caching object creation/changes.
|
||||
"""
|
||||
self.cache(instance, remove_existing=not created)
|
||||
try:
|
||||
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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user