only add index flag if DB_GIN_TRGM is set

This commit is contained in:
j 2012-03-27 13:26:51 +02:00
parent 56f9e3f3d1
commit 577afd682e
3 changed files with 3 additions and 2 deletions

View file

@ -133,7 +133,7 @@ attrs = {
'sortvalue': models.CharField(max_length=1000, null=True, db_index=True), 'sortvalue': models.CharField(max_length=1000, null=True, db_index=True),
#run this CREATE INDEX clip_clip_findvalue_idx ON clip_clip USING gin (findvalue gin_trgm_ops); #run this CREATE INDEX clip_clip_findvalue_idx ON clip_clip USING gin (findvalue gin_trgm_ops);
'findvalue': models.TextField(null=True, db_index=True), 'findvalue': models.TextField(null=True, db_index=settings.DB_GIN_TRGM),
} }
for name in settings.CONFIG['clipLayers']: for name in settings.CONFIG['clipLayers']:
attrs[name] = models.BooleanField(default=False, db_index=True) attrs[name] = models.BooleanField(default=False, db_index=True)

View file

@ -1295,7 +1295,7 @@ class ItemFind(models.Model):
item = models.ForeignKey('Item', related_name='find', db_index=True) item = models.ForeignKey('Item', related_name='find', db_index=True)
key = models.CharField(max_length=200, db_index=True) key = models.CharField(max_length=200, db_index=True)
#CREATE INDEX item_itemfind_value_idx ON item_itemfind USING gin (value gin_trgm_ops); #CREATE INDEX item_itemfind_value_idx ON item_itemfind USING gin (value gin_trgm_ops);
value = models.TextField(blank=True, db_index=True) value = models.TextField(blank=True, db_index=settings.DB_GIN_TRGM)
def __unicode__(self): def __unicode__(self):
return u"%s=%s" % (self.key, self.value) return u"%s=%s" % (self.key, self.value)

View file

@ -183,6 +183,7 @@ ITEM_POSTER = join(SCRIPT_ROOT, 'poster')
ITEM_ICON = join(SCRIPT_ROOT, 'item_icon') ITEM_ICON = join(SCRIPT_ROOT, 'item_icon')
LIST_ICON = join(SCRIPT_ROOT, 'list_icon') LIST_ICON = join(SCRIPT_ROOT, 'list_icon')
DB_GIN_TRGM = False
#you can ignore things below this line #you can ignore things below this line
#========================================================================= #=========================================================================