trigger upgrade_db in postupdate

This commit is contained in:
j 2014-08-11 15:02:24 +02:00
parent 66b132efa4
commit a0cd8d8a1f
2 changed files with 21 additions and 18 deletions

View file

@ -89,23 +89,8 @@ def command_postupdate(*args):
if old <= '20140521-65-e14c686' and new > '20140521-65-e14c686':
if not os.path.exists(settings.db_path):
r('./ctl', 'setup')
if old <= '20140525-92-eac91e7' and new > '20140525-92-eac91e7':
import user.models
for u in user.models.User.query:
u.update_name()
u.save()
import item.models
for f in item.models.File.query:
changed = False
for key in ('mediastate', 'coverRatio', 'previewRatio'):
if key in f.info:
del f.info[key]
changed = True
if changed:
f.save()
if old <= '20140526-118-d451eb3' and new > '20140526-118-d451eb3':
import item.models
item.models.Find.query.filter_by(key='list').delete()
import setup
setup.upgrade_db(old, new)
def command_setup(*args):
"""

View file

@ -180,7 +180,25 @@ PRAGMA journal_mode=WAL
run_sql(statement)
upgrade_db('0')
def upgrade_db(old):
def upgrade_db(old, new=None):
if new:
if old <= '20140525-92-eac91e7' and new > '20140525-92-eac91e7':
import user.models
for u in user.models.User.query:
u.update_name()
u.save()
import item.models
for f in item.models.File.query:
changed = False
for key in ('mediastate', 'coverRatio', 'previewRatio'):
if key in f.info:
del f.info[key]
changed = True
if changed:
f.save()
if old <= '20140526-118-d451eb3' and new > '20140526-118-d451eb3':
import item.models
item.models.Find.query.filter_by(key='list').delete()
if old <= '20140527-120-3cb9819':
run_sql('CREATE INDEX ix_find_findvalue ON find (findvalue)')