'Add uuid column'

def upgrade_version_7(self):

    self.db.execute(u'\n                                ALTER    TABLE    books    ADD    COLUMN    uuid    TEXT;\n                                DROP    TRIGGER    IF    EXISTS    books_insert_trg;\n                                DROP    TRIGGER    IF    EXISTS    books_update_trg;\n                                UPDATE    books    SET    uuid=uuid4();\n\n                                CREATE    TRIGGER    books_insert_trg    AFTER    INSERT    ON    books\n                                BEGIN\n                                                UPDATE    books    SET    sort=title_sort(NEW.title),uuid=uuid4()    WHERE    id=NEW.id;\n                                END;\n\n                                CREATE    TRIGGER    books_update_trg    AFTER    UPDATE    ON    books\n                                BEGIN\n                                                UPDATE    books    SET    sort=title_sort(NEW.title)    WHERE    id=NEW.id;\n                                END;\n\n                                DROP    VIEW    IF    EXISTS    meta;\n                                CREATE    VIEW    meta    AS\n                                SELECT    id,    title,\n                                                            (SELECT    sortconcat(bal.id,    name)    FROM    books_authors_link    AS    bal    JOIN    authors    ON(author    =    authors.id)    WHERE    book    =    books.id)    authors,\n                                                            (SELECT    name    FROM    publishers    WHERE    publishers.id    IN    (SELECT    publisher    from    books_publishers_link    WHERE    book=books.id))    publisher,\n                                                            (SELECT    rating    FROM    ratings    WHERE    ratings.id    IN    (SELECT    rating    from    books_ratings_link    WHERE    book=books.id))    rating,\n                                                            timestamp,\n                                                            (SELECT    MAX(uncompressed_size)    FROM    data    WHERE    book=books.id)    size,\n                                                            (SELECT    concat(name)    FROM    tags    WHERE    tags.id    IN    (SELECT    tag    from    books_tags_link    WHERE    book=books.id))    tags,\n                                                            (SELECT    text    FROM    comments    WHERE    book=books.id)    comments,\n                                                            (SELECT    name    FROM    series    WHERE    series.id    IN    (SELECT    series    FROM    books_series_link    WHERE    book=books.id))    series,\n                                                            series_index,\n                                                            sort,\n                                                            author_sort,\n                                                            (SELECT    concat(format)    FROM    data    WHERE    data.book=books.id)    formats,\n                                                            isbn,\n                                                            path,\n                                                            lccn,\n                                                            pubdate,\n                                                            flags,\n                                                            uuid\n                                FROM    books;\n                                ')
