'Update indexes/triggers for new books table'

def upgrade_version_5(self):

    self.db.execute(u'\n                                CREATE    INDEX    authors_idx    ON    books    (author_sort    COLLATE    NOCASE);\n                                CREATE    INDEX    books_idx    ON    books    (sort    COLLATE    NOCASE);\n                                CREATE    TRIGGER    books_delete_trg\n                                                AFTER    DELETE    ON    books\n                                                BEGIN\n                                                                DELETE    FROM    books_authors_link    WHERE    book=OLD.id;\n                                                                DELETE    FROM    books_publishers_link    WHERE    book=OLD.id;\n                                                                DELETE    FROM    books_ratings_link    WHERE    book=OLD.id;\n                                                                DELETE    FROM    books_series_link    WHERE    book=OLD.id;\n                                                                DELETE    FROM    books_tags_link    WHERE    book=OLD.id;\n                                                                DELETE    FROM    data    WHERE    book=OLD.id;\n                                                                DELETE    FROM    comments    WHERE    book=OLD.id;\n                                                                DELETE    FROM    conversion_options    WHERE    book=OLD.id;\n                                END;\n                                CREATE    TRIGGER    books_insert_trg\n                                                AFTER    INSERT    ON    books\n                                                BEGIN\n                                                UPDATE    books    SET    sort=title_sort(NEW.title)    WHERE    id=NEW.id;\n                                END;\n                                CREATE    TRIGGER    books_update_trg\n                                                AFTER    UPDATE    ON    books\n                                                BEGIN\n                                                UPDATE    books    SET    sort=title_sort(NEW.title)    WHERE    id=NEW.id;\n                                END;\n\n                                UPDATE    books    SET    sort=title_sort(title)    WHERE    sort    IS    NULL;\n                                ')
