more sort fixes. []->None
This commit is contained in:
parent
30f6f6860f
commit
591fa089ce
2 changed files with 17 additions and 1 deletions
|
@ -82,4 +82,4 @@ USER_AGENT = 'OpenMediaLibrary/%s' % VERSION
|
|||
|
||||
DEBUG_HTTP = server.get('debug_http', False)
|
||||
|
||||
DB_VERSION = 1
|
||||
DB_VERSION = 2
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue