only migrate if user exists
This commit is contained in:
parent
d3aab286f8
commit
529a01269d
1 changed files with 10 additions and 9 deletions
19
oml/setup.py
19
oml/setup.py
|
@ -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]'):
|
||||
|
|
Loading…
Reference in a new issue