with session
This commit is contained in:
parent
03c24396e0
commit
14ede9d1b1
1 changed files with 23 additions and 20 deletions
43
oml/setup.py
43
oml/setup.py
|
@ -184,22 +184,24 @@ PRAGMA journal_mode=WAL
|
||||||
def upgrade_db(old, new=None):
|
def upgrade_db(old, new=None):
|
||||||
if new:
|
if new:
|
||||||
if old <= '20140525-92-eac91e7' and new > '20140525-92-eac91e7':
|
if old <= '20140525-92-eac91e7' and new > '20140525-92-eac91e7':
|
||||||
import user.models
|
with db.session():
|
||||||
for u in user.models.User.query:
|
import user.models
|
||||||
u.update_name()
|
for u in user.models.User.query:
|
||||||
u.save()
|
u.update_name()
|
||||||
import item.models
|
u.save()
|
||||||
for f in item.models.File.query:
|
import item.models
|
||||||
changed = False
|
for f in item.models.File.query:
|
||||||
for key in ('mediastate', 'coverRatio', 'previewRatio'):
|
changed = False
|
||||||
if key in f.info:
|
for key in ('mediastate', 'coverRatio', 'previewRatio'):
|
||||||
del f.info[key]
|
if key in f.info:
|
||||||
changed = True
|
del f.info[key]
|
||||||
if changed:
|
changed = True
|
||||||
f.save()
|
if changed:
|
||||||
|
f.save()
|
||||||
if old <= '20140526-118-d451eb3' and new > '20140526-118-d451eb3':
|
if old <= '20140526-118-d451eb3' and new > '20140526-118-d451eb3':
|
||||||
import item.models
|
with db.session():
|
||||||
item.models.Find.query.filter_by(key='list').delete()
|
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)')
|
||||||
|
@ -224,11 +226,12 @@ def upgrade_db(old, new=None):
|
||||||
]
|
]
|
||||||
for sql in statements:
|
for sql in statements:
|
||||||
run_sql(sql.format(oid=settings.OLD_USER_ID, nid=settings.USER_ID))
|
run_sql(sql.format(oid=settings.OLD_USER_ID, nid=settings.USER_ID))
|
||||||
if old <= '20151201-378-75164a8':
|
if old <= '20151201-384-03c2439':
|
||||||
import item.models
|
with db.session():
|
||||||
for i in item.models.Item.query:
|
import item.models
|
||||||
for f in i.files.all():
|
for i in item.models.Item.query:
|
||||||
f.move()
|
for f in i.files.all():
|
||||||
|
f.move()
|
||||||
|
|
||||||
def create_default_lists(user_id=None):
|
def create_default_lists(user_id=None):
|
||||||
with db.session():
|
with db.session():
|
||||||
|
|
Loading…
Reference in a new issue