fix index creation
This commit is contained in:
parent
e6aaf0aa6b
commit
2eafb9b3f8
2 changed files with 6 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
|
|
||||||
from django.core.management.base import BaseCommand
|
from django.core.management.base import BaseCommand
|
||||||
from django.db import connection
|
from django.db import connection, transaction
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
import monkey_patch.models
|
import monkey_patch.models
|
||||||
|
@ -42,3 +42,4 @@ class Command(BaseCommand):
|
||||||
name = 'findvalue'
|
name = 'findvalue'
|
||||||
if name not in indexes:
|
if name not in indexes:
|
||||||
create_table("%s_%s_idx"%(table_name, name), table_name, name)
|
create_table("%s_%s_idx"%(table_name, name), table_name, name)
|
||||||
|
transaction.commit_unless_managed()
|
||||||
|
|
|
@ -83,6 +83,10 @@ class Command(BaseCommand):
|
||||||
if name not in db_fields:
|
if name not in db_fields:
|
||||||
sql = 'ALTER TABLE "%s" ADD COLUMN "%s" %s' % (table_name, name, col_type)
|
sql = 'ALTER TABLE "%s" ADD COLUMN "%s" %s' % (table_name, name, col_type)
|
||||||
changes.append(sql)
|
changes.append(sql)
|
||||||
|
sql = 'UPDATE "%s" SET "%s"=FALSE WHERE "%s" IS NULL' % (
|
||||||
|
table_name, name, name
|
||||||
|
)
|
||||||
|
changes.append(sql)
|
||||||
sql = 'CREATE INDEX "%s_%s_idx" ON "%s" ("%s")' % (table_name, name,
|
sql = 'CREATE INDEX "%s_%s_idx" ON "%s" ("%s")' % (table_name, name,
|
||||||
table_name, name)
|
table_name, name)
|
||||||
changes.append(sql)
|
changes.append(sql)
|
||||||
|
|
Loading…
Reference in a new issue