From 2eafb9b3f8c5c9f38981433f1b1baf591cafaea8 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 31 Jan 2013 20:41:46 +0000 Subject: [PATCH] fix index creation --- pandora/item/management/commands/sqlfindindex.py | 3 ++- pandora/item/management/commands/sync_itemsort.py | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pandora/item/management/commands/sqlfindindex.py b/pandora/item/management/commands/sqlfindindex.py index 88ca8144..1f74f4b6 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 dd4ac590..926c380a 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)