add indices to upgrade check if missing

This commit is contained in:
Damien Elmes 2011-10-26 12:19:12 +09:00
parent 4668b1a210
commit 37ea359931
2 changed files with 9 additions and 0 deletions

View file

@ -53,6 +53,11 @@ class Upgrader(object):
# old version? # old version?
if db.scalar("select version from decks") != 65: if db.scalar("select version from decks") != 65:
return return
# ensure we have indices for checks below
db.executescript("""
create index if not exists ix_cards_factId on cards (factId);
create index if not exists ix_fields_factId on fieldModels (factId);
analyze;""")
# fields missing a field model? # fields missing a field model?
if db.list(""" if db.list("""
select id from fields where fieldModelId not in ( select id from fields where fieldModelId not in (

View file

@ -193,6 +193,10 @@ def maxID(db):
def guid64(): def guid64():
return random.randint(-sys.maxint-1, sys.maxint) return random.randint(-sys.maxint-1, sys.maxint)
def guid32():
max = 2**32
return random.randint(0, max-1)
# Fields # Fields
############################################################################## ##############################################################################