fix ordinal problems rather than aborting upgrade

This commit is contained in:
Damien Elmes 2012-01-24 23:10:37 +09:00
parent 92ee7597a9
commit be8bec5bc4

View file

@ -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