diff --git a/pandora/item/management/commands/sqlfindindex.py b/pandora/item/management/commands/sqlfindindex.py index 88ca8144e..1f74f4b6d 100644 --- a/pandora/item/management/commands/sqlfindindex.py +++ b/pandora/item/management/commands/sqlfindindex.py @@ -3,7 +3,7 @@ from optparse import make_option from django.core.management.base import BaseCommand -from django.db import connection +from django.db import connection, transaction from django.conf import settings import monkey_patch.models @@ -42,3 +42,4 @@ class Command(BaseCommand): name = 'findvalue' if name not in indexes: create_table("%s_%s_idx"%(table_name, name), table_name, name) + transaction.commit_unless_managed() diff --git a/pandora/item/management/commands/sync_itemsort.py b/pandora/item/management/commands/sync_itemsort.py index dd4ac590a..926c380af 100644 --- a/pandora/item/management/commands/sync_itemsort.py +++ b/pandora/item/management/commands/sync_itemsort.py @@ -83,6 +83,10 @@ class Command(BaseCommand): if name not in db_fields: sql = 'ALTER TABLE "%s" ADD COLUMN "%s" %s' % (table_name, name, col_type) 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, table_name, name) changes.append(sql)