more sort fixes. []->None

This commit is contained in:
j 2016-01-16 15:04:07 +05:30
parent 30f6f6860f
commit 591fa089ce
2 changed files with 17 additions and 1 deletions

View file

@ -82,4 +82,4 @@ USER_AGENT = 'OpenMediaLibrary/%s' % VERSION
DEBUG_HTTP = server.get('debug_http', False)
DB_VERSION = 1
DB_VERSION = 2

View file

@ -280,6 +280,8 @@ class Update(Thread):
self.status('Migrating database...')
if db_version < 1:
db_version = migrate_1()
if db_version < 2:
db_version = migrate_2()
settings.server['db_version'] = settings.DB_VERSION
def run(self):
@ -299,3 +301,17 @@ def migrate_1():
s.item.update_sort()
session.commit()
return 1
def migrate_2():
with db.session() as session:
import item.models
for s in item.models.Sort.query.filter_by(author=''):
s.item.update_sort()
for s in item.models.Sort.query.filter_by(publisher=''):
s.item.update_sort()
for s in item.models.Sort.query.filter_by(language=''):
s.item.update_sort()
for s in item.models.Sort.query.filter_by(place=''):
s.item.update_sort()
session.commit()
return 2