catch incorrect ordinals on upgrade

This commit is contained in:
Damien Elmes 2011-11-28 16:57:58 +09:00
parent cd76706a2f
commit bd29318168
2 changed files with 18 additions and 12 deletions

View file

@ -21,7 +21,7 @@ class CardStats(object):
def report(self): def report(self):
c = self.card c = self.card
fmt = lambda x, **kwargs: fmtTimeSpan(x, short=True, **kwargs) fmt = lambda x, **kwargs: fmtTimeSpan(x, short=True, **kwargs)
self.txt = "<table width=100%%>" self.txt = "<table width=100%>"
self.addLine(_("Added"), self.date(c.id/1000)) self.addLine(_("Added"), self.date(c.id/1000))
first = self.col.db.scalar( first = self.col.db.scalar(
"select min(id) from revlog where cid = ?", c.id) "select min(id) from revlog where cid = ?", c.id)

View file

@ -84,6 +84,12 @@ analyze;""")
cardModels cm, facts f where cm.modelId = f.modelId and cardModels cm, facts f where cm.modelId = f.modelId and
f.id = cards.factId)"""): f.id = cards.factId)"""):
return return
# cards with the wrong ordinal?
if db.list("""
select c.id from cards c, cardModels cm
where c.cardModelId = cm.id
and c.ordinal != cm.ordinal"""):
return
# facts missing a card? # facts missing a card?
if db.list(""" if db.list("""
select facts.id from facts select facts.id from facts