Add index to features ArrayField

This commit is contained in:
Jeremy Stretch 2025-07-25 08:42:33 -04:00
parent 8fd8445f6d
commit 5fe4c96ecf
2 changed files with 11 additions and 0 deletions

View File

@ -1,4 +1,5 @@
import django.contrib.postgres.fields
import django.contrib.postgres.indexes
import django.db.models.deletion
from django.db import migrations, models
@ -48,6 +49,12 @@ class Migration(migrations.Migration):
options={
'verbose_name': 'object type',
'verbose_name_plural': 'object types',
'indexes': [
django.contrib.postgres.indexes.GinIndex(
fields=['features'],
name='core_object_feature_aec4de_gin'
),
]
},
bases=('contenttypes.contenttype',),
managers=[],

View File

@ -1,5 +1,6 @@
from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import ArrayField
from django.contrib.postgres.indexes import GinIndex
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.utils.translation import gettext as _
@ -126,6 +127,9 @@ class ObjectType(ContentType):
class Meta:
verbose_name = _('object type')
verbose_name_plural = _('object types')
indexes = [
GinIndex(fields=['features']),
]
@property
def app_labeled_name(self):