'Create the last_read_positions table'

def upgrade_version_22(self):

    self.db.execute(u"\nDROP    TABLE    IF    EXISTS    last_read_positions;\nCREATE    TABLE    last_read_positions    (    id    INTEGER    PRIMARY    KEY,\n                book    INTEGER    NOT    NULL,\n                format    TEXT    NOT    NULL    COLLATE    NOCASE,\n                user    TEXT    NOT    NULL,\n                device    TEXT    NOT    NULL,\n                cfi    TEXT    NOT    NULL,\n                epoch    REAL    NOT    NULL,\n                pos_frac    REAL    NOT    NULL    DEFAULT    0,\n                UNIQUE(user,    device,    book,    format)\n);\nDROP    INDEX    IF    EXISTS    lrp_idx;\nCREATE    INDEX    lrp_idx    ON    last_read_positions    (book);\n\nDROP    TRIGGER    IF    EXISTS    books_delete_trg;\nCREATE    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    books_languages_link    WHERE    book=OLD.id;\n                                DELETE    FROM    data    WHERE    book=OLD.id;\n                                DELETE    FROM    last_read_positions    WHERE    book=OLD.id;\n                                DELETE    FROM    comments    WHERE    book=OLD.id;\n                                DELETE    FROM    conversion_options    WHERE    book=OLD.id;\n                                DELETE    FROM    books_plugin_data    WHERE    book=OLD.id;\n                                DELETE    FROM    identifiers    WHERE    book=OLD.id;\nEND;\n\nDROP    TRIGGER    IF    EXISTS    fkc_lrp_insert;\nDROP    TRIGGER    IF    EXISTS    fkc_lrp_update;\nCREATE    TRIGGER    fkc_lrp_insert\n                                BEFORE    INSERT    ON    last_read_positions\n                                BEGIN\n                                                SELECT    CASE\n                                                                WHEN    (SELECT    id    from    books    WHERE    id=NEW.book)    IS    NULL\n                                                                THEN    RAISE(ABORT,    'Foreign    key    violation:    book    not    in    books')\n                                                END;\n                                END;\nCREATE    TRIGGER    fkc_lrp_update\n                                BEFORE    UPDATE    OF    book    ON    last_read_positions\n                                BEGIN\n                                                SELECT    CASE\n                                                                WHEN    (SELECT    id    from    books    WHERE    id=NEW.book)    IS    NULL\n                                                                THEN    RAISE(ABORT,    'Foreign    key    violation:    book    not    in    books')\n                                                END;\n                                END;\n\n                                ")
