How to create GIN index in Django migration How to create GIN index in Django migration postgresql postgresql

How to create GIN index in Django migration


Haven't yet had a chance to migrate my old manual CREATE INDEX codes to the new system introduced in 1.11 but my understanding is

from django.contrib.postgres.indexes import GinIndeximport django.contrib.postgres.search as pg_search    class EntryLine(models.Model):    speaker = models.CharField(max_length=512, db_index=True)    text = models.TextField()    sv = pg_search.SearchVectorField(null=True)     class Meta:        indexes = [GinIndex(fields=['sv'])]

Is what's required. Raw SQL CREATE INDEX statements need not be used any more.