mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
add created field to models so we can tell if they were originally the same
This commit is contained in:
parent
5856ad7545
commit
f969aec03f
2 changed files with 9 additions and 6 deletions
|
@ -65,20 +65,22 @@ class Model(object):
|
|||
else:
|
||||
self.id = None
|
||||
self.name = u""
|
||||
self.mod = intTime()
|
||||
self.crt = intTime()
|
||||
self.mod = self.crt
|
||||
self.conf = defaultConf.copy()
|
||||
self.css = ""
|
||||
self.fields = []
|
||||
self.templates = []
|
||||
|
||||
def load(self):
|
||||
(self.mod,
|
||||
(self.crt,
|
||||
self.mod,
|
||||
self.name,
|
||||
self.fields,
|
||||
self.templates,
|
||||
self.conf,
|
||||
self.css) = self.deck.db.first("""
|
||||
select mod, name, flds, tmpls, conf, css from models where id = ?""", self.id)
|
||||
select crt, mod, name, flds, tmpls, conf, css from models where id = ?""", self.id)
|
||||
self.fields = simplejson.loads(self.fields)
|
||||
self.templates = simplejson.loads(self.templates)
|
||||
self.conf = simplejson.loads(self.conf)
|
||||
|
@ -87,8 +89,8 @@ select mod, name, flds, tmpls, conf, css from models where id = ?""", self.id)
|
|||
self.mod = intTime()
|
||||
self.css = self.genCSS()
|
||||
ret = self.deck.db.execute("""
|
||||
insert or replace into models values (?, ?, ?, ?, ?, ?, ?)""",
|
||||
self.id, self.mod, self.name,
|
||||
insert or replace into models values (?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
self.id, self.crt, self.mod, self.name,
|
||||
simplejson.dumps(self.fields),
|
||||
simplejson.dumps(self.templates),
|
||||
simplejson.dumps(self.conf),
|
||||
|
|
|
@ -111,6 +111,7 @@ create table if not exists fsums (
|
|||
|
||||
create table if not exists models (
|
||||
id integer primary key,
|
||||
crt integer not null,
|
||||
mod integer not null,
|
||||
name text not null,
|
||||
flds text not null,
|
||||
|
@ -314,7 +315,7 @@ from facts order by created""")
|
|||
import anki.models
|
||||
_moveTable(db, "models")
|
||||
db.execute("""
|
||||
insert into models select id, cast(modified as int),
|
||||
insert into models select id, cast(created as int), cast(modified as int),
|
||||
name, "{}", "{}", ?, "" from models2""", simplejson.dumps(
|
||||
anki.models.defaultConf))
|
||||
db.execute("drop table models2")
|
||||
|
|
Loading…
Reference in a new issue