diff --git a/anki/deck.py b/anki/deck.py index f439dcaae..9892c846d 100644 --- a/anki/deck.py +++ b/anki/deck.py @@ -1910,43 +1910,25 @@ class DeckStorage(object): deck = DeckStorage._init(s) else: ver = s.scalar("select version from decks limit 1") - try: - if ver < 5: - # add missing deck fields - s.execute(""" -alter table decks add column newCardsPerDay integer not null default 20""") - if ver < 6: - s.execute(""" -alter table decks add column sessionRepLimit integer not null default 100""") - s.execute(""" -alter table decks add column sessionTimeLimit integer not null default 1800""") - if ver < 11: - s.execute(""" -alter table decks add column utcOffset numeric(10, 2) not null default 0""") - if ver < 13: - s.execute(""" -alter table decks add column cardCount integer not null default 0""") - s.execute(""" -alter table decks add column factCount integer not null default 0""") - s.execute(""" -alter table decks add column failedNowCount integer not null default 0""") - s.execute(""" -alter table decks add column failedSoonCount integer not null default 0""") - s.execute(""" -alter table decks add column revCount integer not null default 0""") - s.execute(""" -alter table decks add column newCount integer not null default 0""") - if ver < 17: - s.execute(""" -alter table decks add column revCardOrder integer not null default 0""") - if ver < 18: - s.execute(""" -alter table cardModels add column allowEmptyAnswer boolean not null default 1""") - if ver < 19: - s.execute(""" -alter table cardModels add column typeAnswer boolean not null default 0""") - except: - pass + if ver < 19: + for st in ( + "decks add column newCardsPerDay integer not null default 20", + "decks add column sessionRepLimit integer not null default 100", + "decks add column sessionTimeLimit integer not null default 1800", + "decks add column utcOffset numeric(10, 2) not null default 0", + "decks add column cardCount integer not null default 0", + "decks add column factCount integer not null default 0", + "decks add column failedNowCount integer not null default 0", + "decks add column failedSoonCount integer not null default 0", + "decks add column revCount integer not null default 0", + "decks add column newCount integer not null default 0", + "decks add column revCardOrder integer not null default 0", + "cardModels add column allowEmptyAnswer boolean not null default 1", + "cardModels add column typeAnswer boolean not null default 0"): + try: + s.execute("alter table " + st) + except: + pass deck = s.query(Deck).get(1) # attach db vars deck.path = path