This commit is contained in:
Kovid Goyal 2015-08-05 17:12:34 +05:30
commit df3f850407
2 changed files with 28 additions and 3 deletions

View File

@ -539,11 +539,11 @@ CREATE TRIGGER fkc_update_books_tags_link_b
CREATE TRIGGER series_insert_trg
AFTER INSERT ON series
BEGIN
UPDATE series SET sort=NEW.name WHERE id=NEW.id;
UPDATE series SET sort=title_sort(NEW.name) WHERE id=NEW.id;
END;
CREATE TRIGGER series_update_trg
AFTER UPDATE ON series
BEGIN
UPDATE series SET sort=NEW.name WHERE id=NEW.id;
UPDATE series SET sort=title_sort(NEW.name) WHERE id=NEW.id;
END;
pragma user_version=21;
pragma user_version=22;

View File

@ -615,3 +615,28 @@ class SchemaUpgrade(object):
self.db.execute(script)
def upgrade_version_21(self):
'''
Write the series sort into the existing sort column in the series table
'''
script = '''
DROP TRIGGER IF EXISTS series_insert_trg;
DROP TRIGGER IF EXISTS series_update_trg;
UPDATE series SET sort=title_sort(name);
CREATE TRIGGER series_insert_trg
AFTER INSERT ON series
BEGIN
UPDATE series SET sort=title_sort(NEW.name) WHERE id=NEW.id;
END;
CREATE TRIGGER series_update_trg
AFTER UPDATE ON series
BEGIN
UPDATE series SET sort=title_sort(NEW.name) WHERE id=NEW.id;
END;
'''
self.db.execute(script)