diff --git a/wagtail/contrib/postgres_search/migrations/0001_initial.py b/wagtail/contrib/postgres_search/migrations/0001_initial.py index 685526071d..66db429adb 100644 --- a/wagtail/contrib/postgres_search/migrations/0001_initial.py +++ b/wagtail/contrib/postgres_search/migrations/0001_initial.py @@ -44,5 +44,11 @@ class Migration(migrations.Migration): 'CREATE INDEX {0}_body_search ON {0} ' 'USING GIN(body_search);'.format(table), 'DROP INDEX {}_body_search;'.format(table), + state_operations=[migrations.AddIndex( + model_name='indexentry', + index=django.contrib.postgres.indexes.GinIndex( + fields=['body_search'], + name='postgres_se_body_se_70ba1a_gin'), + )], ), ] diff --git a/wagtail/contrib/postgres_search/models.py b/wagtail/contrib/postgres_search/models.py index 31e46d148f..81451134e0 100644 --- a/wagtail/contrib/postgres_search/models.py +++ b/wagtail/contrib/postgres_search/models.py @@ -3,6 +3,7 @@ from __future__ import absolute_import, unicode_literals from django.apps import apps from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.models import ContentType +from django.contrib.postgres.indexes import GinIndex from django.contrib.postgres.search import SearchVectorField from django.db.models import CASCADE, ForeignKey, Model, TextField from django.db.models.functions import Cast @@ -53,7 +54,7 @@ class IndexEntry(Model): unique_together = ('content_type', 'object_id') verbose_name = _('index entry') verbose_name_plural = _('index entries') - # TODO: Move here the GIN index from the migration. + indexes = [GinIndex(['body_search'])] def __str__(self): return '%s: %s' % (self.content_type.name, self.content_object)