Remove index from CachedValue.value

This commit is contained in:
jeremystretch 2022-12-02 09:49:35 -05:00
parent 774b154e47
commit a37d6386db
2 changed files with 0 additions and 24 deletions

View File

@ -2,7 +2,6 @@ import sys
import uuid
import django.db.models.deletion
import django.db.models.functions.text
import django.db.models.lookups
from django.core import management
from django.db import migrations, models
@ -47,10 +46,6 @@ class Migration(migrations.Migration):
],
options={
'ordering': ('weight', 'object_type', 'object_id'),
'indexes': (
models.Index(condition=models.Q(django.db.models.lookups.LessThan(django.db.models.functions.text.Length('value'), 1024)), fields=['value'], name='extras_cachedvalue_value'),
models.Index(condition=models.Q(django.db.models.lookups.LessThan(django.db.models.functions.text.Length('value'), 1024)), fields=['value'], name='extras_cachedvalue_value_like', opclasses=['text_pattern_ops']),
)
},
),
migrations.RunPython(

View File

@ -2,9 +2,6 @@ import uuid
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.db.models import Index, Q
from django.db.models.functions import Length
from django.db.models.lookups import LessThan
from utilities.fields import RestrictedGenericForeignKey
@ -12,9 +9,6 @@ __all__ = (
'CachedValue',
)
# Maximum cached value length to index (see #11046)
INDEX_MAX = 1024
class CachedValue(models.Model):
id = models.UUIDField(
@ -49,19 +43,6 @@ class CachedValue(models.Model):
class Meta:
ordering = ('weight', 'object_type', 'object_id')
indexes = (
Index(
fields=['value'],
name='extras_cachedvalue_value',
condition=Q(LessThan(Length('value'), INDEX_MAX))
),
Index(
fields=['value'],
name='extras_cachedvalue_value_like',
opclasses=['text_pattern_ops'],
condition=Q(LessThan(Length('value'), INDEX_MAX))
),
)
def __str__(self):
return f'{self.object_type} {self.object_id}: {self.field}={self.value}'