trigger upgrade_db in postupdate
This commit is contained in:
parent
66b132efa4
commit
a0cd8d8a1f
2 changed files with 21 additions and 18 deletions
|
@ -89,23 +89,8 @@ def command_postupdate(*args):
|
||||||
if old <= '20140521-65-e14c686' and new > '20140521-65-e14c686':
|
if old <= '20140521-65-e14c686' and new > '20140521-65-e14c686':
|
||||||
if not os.path.exists(settings.db_path):
|
if not os.path.exists(settings.db_path):
|
||||||
r('./ctl', 'setup')
|
r('./ctl', 'setup')
|
||||||
if old <= '20140525-92-eac91e7' and new > '20140525-92-eac91e7':
|
import setup
|
||||||
import user.models
|
setup.upgrade_db(old, new)
|
||||||
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()
|
|
||||||
|
|
||||||
def command_setup(*args):
|
def command_setup(*args):
|
||||||
"""
|
"""
|
||||||
|
|
20
oml/setup.py
20
oml/setup.py
|
@ -180,7 +180,25 @@ PRAGMA journal_mode=WAL
|
||||||
run_sql(statement)
|
run_sql(statement)
|
||||||
upgrade_db('0')
|
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':
|
if old <= '20140527-120-3cb9819':
|
||||||
run_sql('CREATE INDEX ix_find_findvalue ON find (findvalue)')
|
run_sql('CREATE INDEX ix_find_findvalue ON find (findvalue)')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue