From be8bec5bc492db780221dd9bf477659fd3ecea60 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Tue, 24 Jan 2012 23:10:37 +0900 Subject: [PATCH] fix ordinal problems rather than aborting upgrade --- anki/upgrade.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/anki/upgrade.py b/anki/upgrade.py index 410edf081..df2aadf97 100644 --- a/anki/upgrade.py +++ b/anki/upgrade.py @@ -81,12 +81,6 @@ select id from cards where cardModelId not in (select cm.id from cardModels cm, facts f where cm.modelId = f.modelId and f.id = cards.factId)"""): 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? if db.list(""" select facts.id from facts @@ -137,6 +131,12 @@ and c.ordinal != cm.ordinal"""): db.execute("pragma page_size = 4096") db.execute("pragma legacy_file_format = 0") + # previous versions sometimes had cards with incorrect ordinals and + # the db check didn't fix that. so we fix it here: + db.execute(""" +update cards set ordinal = (select ordinal from cardModels +where id = cards.cardModelId)""") + # notes ########### # tags should have a leading and trailing space if not empty, and not