only migrate if user exists

This commit is contained in:
j 2016-01-07 15:53:41 +05:30
parent d3aab286f8
commit 529a01269d

View file

@ -248,21 +248,22 @@ def upgrade_db(old, new=None):
if old <= '20160106-497-c86ba8a':
with db.session() as session:
u = User.get(settings.USER_ID)
l = u.library
for i in u.items.all():
if not i in l.items:
l.items.append(i)
session.add(l)
u.clear_list_cache()
for u in User.query.filter_by(peered=True):
if u:
l = u.library
for i in u.items.all():
if not i in l.items:
l.items.append(i)
session.add(l)
u.clear_list_cache()
l.items_count()
session.commit()
for u in User.query.filter_by(peered=True):
l = u.library
for i in u.items.all():
if not i in l.items:
l.items.append(i)
session.add(l)
u.clear_list_cache()
l.items_count()
session.commit()
if old <= '20160107-508-a0c1970':
with db.session() as session:
for l in List.query.filter_by(name=' [2]'):