mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
improve upgrade code
This commit is contained in:
parent
3670a0cb7b
commit
fe17d6c53e
1 changed files with 19 additions and 37 deletions
56
anki/deck.py
56
anki/deck.py
|
@ -1910,43 +1910,25 @@ class DeckStorage(object):
|
||||||
deck = DeckStorage._init(s)
|
deck = DeckStorage._init(s)
|
||||||
else:
|
else:
|
||||||
ver = s.scalar("select version from decks limit 1")
|
ver = s.scalar("select version from decks limit 1")
|
||||||
try:
|
if ver < 19:
|
||||||
if ver < 5:
|
for st in (
|
||||||
# add missing deck fields
|
"decks add column newCardsPerDay integer not null default 20",
|
||||||
s.execute("""
|
"decks add column sessionRepLimit integer not null default 100",
|
||||||
alter table decks add column newCardsPerDay integer not null default 20""")
|
"decks add column sessionTimeLimit integer not null default 1800",
|
||||||
if ver < 6:
|
"decks add column utcOffset numeric(10, 2) not null default 0",
|
||||||
s.execute("""
|
"decks add column cardCount integer not null default 0",
|
||||||
alter table decks add column sessionRepLimit integer not null default 100""")
|
"decks add column factCount integer not null default 0",
|
||||||
s.execute("""
|
"decks add column failedNowCount integer not null default 0",
|
||||||
alter table decks add column sessionTimeLimit integer not null default 1800""")
|
"decks add column failedSoonCount integer not null default 0",
|
||||||
if ver < 11:
|
"decks add column revCount integer not null default 0",
|
||||||
s.execute("""
|
"decks add column newCount integer not null default 0",
|
||||||
alter table decks add column utcOffset numeric(10, 2) not null default 0""")
|
"decks add column revCardOrder integer not null default 0",
|
||||||
if ver < 13:
|
"cardModels add column allowEmptyAnswer boolean not null default 1",
|
||||||
s.execute("""
|
"cardModels add column typeAnswer boolean not null default 0"):
|
||||||
alter table decks add column cardCount integer not null default 0""")
|
try:
|
||||||
s.execute("""
|
s.execute("alter table " + st)
|
||||||
alter table decks add column factCount integer not null default 0""")
|
except:
|
||||||
s.execute("""
|
pass
|
||||||
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
|
|
||||||
deck = s.query(Deck).get(1)
|
deck = s.query(Deck).get(1)
|
||||||
# attach db vars
|
# attach db vars
|
||||||
deck.path = path
|
deck.path = path
|
||||||
|
|
Loading…
Reference in a new issue