another fix for new installs

This commit is contained in:
j 2017-08-19 18:32:09 +02:00
parent 58f516ff46
commit 9145ef5df6

View file

@ -487,6 +487,7 @@ def update_database():
item.models.update_sort_table() item.models.update_sort_table()
def add_listitem_index(): def add_listitem_index():
if db.table_exists('listitem'):
with db.session() as session: with db.session() as session:
sql = "SELECT COUNT(*) AS c,list_id,item_id FROM listitem GROUP BY list_id, item_id HAVING c>1" sql = "SELECT COUNT(*) AS c,list_id,item_id FROM listitem GROUP BY list_id, item_id HAVING c>1"
doubles = [r for r in session.execute(sql)] doubles = [r for r in session.execute(sql)]
@ -502,6 +503,7 @@ def add_listitem_index():
session.commit() session.commit()
def add_useritem_index(): def add_useritem_index():
if db.table_exists('useritem'):
with db.session() as session: with db.session() as session:
sql = "SELECT COUNT(*) AS c,user_id,item_id FROM useritem GROUP BY user_id, item_id HAVING c>1" sql = "SELECT COUNT(*) AS c,user_id,item_id FROM useritem GROUP BY user_id, item_id HAVING c>1"
doubles = [r for r in session.execute(sql)] doubles = [r for r in session.execute(sql)]