forked from 0x2620/pandora
only create index in sqlfindindex not during migration
This commit is contained in:
parent
9cbf62267f
commit
10183a9f06
2 changed files with 4 additions and 4 deletions
|
@ -13,7 +13,7 @@ class Migration(SchemaMigration):
|
||||||
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||||
('entity', self.gf('django.db.models.fields.related.ForeignKey')(related_name='find', to=orm['entity.Entity'])),
|
('entity', self.gf('django.db.models.fields.related.ForeignKey')(related_name='find', to=orm['entity.Entity'])),
|
||||||
('key', self.gf('django.db.models.fields.CharField')(max_length=200, db_index=True)),
|
('key', self.gf('django.db.models.fields.CharField')(max_length=200, db_index=True)),
|
||||||
('value', self.gf('django.db.models.fields.TextField')(db_index=True, blank=True)),
|
('value', self.gf('django.db.models.fields.TextField')(db_index=False, blank=True)),
|
||||||
))
|
))
|
||||||
db.send_create_signal('entity', ['Find'])
|
db.send_create_signal('entity', ['Find'])
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class Migration(SchemaMigration):
|
||||||
'entity': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'find'", 'to': "orm['entity.Entity']"}),
|
'entity': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'find'", 'to': "orm['entity.Entity']"}),
|
||||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
'key': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_index': 'True'}),
|
'key': ('django.db.models.fields.CharField', [], {'max_length': '200', 'db_index': 'True'}),
|
||||||
'value': ('django.db.models.fields.TextField', [], {'db_index': 'True', 'blank': 'True'})
|
'value': ('django.db.models.fields.TextField', [], {'db_index': 'False', 'blank': 'True'})
|
||||||
},
|
},
|
||||||
'item.item': {
|
'item.item': {
|
||||||
'Meta': {'object_name': 'Item'},
|
'Meta': {'object_name': 'Item'},
|
||||||
|
|
|
@ -24,7 +24,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def handle(self, **options):
|
def handle(self, **options):
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
def create_table(index, table, key):
|
def create_index(index, table, key):
|
||||||
sql = 'CREATE INDEX "%s" ON "%s" USING gin ("%s" gin_trgm_ops)' % (index, table, key)
|
sql = 'CREATE INDEX "%s" ON "%s" USING gin ("%s" gin_trgm_ops)' % (index, table, key)
|
||||||
if options['debug']:
|
if options['debug']:
|
||||||
print sql
|
print sql
|
||||||
|
@ -40,5 +40,5 @@ class Command(BaseCommand):
|
||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
indexes = connection.introspection.get_indexes(cursor, table_name)
|
indexes = connection.introspection.get_indexes(cursor, table_name)
|
||||||
if name not in indexes:
|
if name not in indexes:
|
||||||
create_table("%s_%s_idx"%(table_name, name), table_name, name)
|
create_index("%s_%s_idx"%(table_name, name), table_name, name)
|
||||||
transaction.commit_unless_managed()
|
transaction.commit_unless_managed()
|
||||||
|
|
Loading…
Reference in a new issue