CREATE TABLE libraryUpdateError (
    _id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    manga_id INTEGER NOT NULL UNIQUE,
    message_id INTEGER NOT NULL,
    last_update INTEGER NOT NULL DEFAULT 0
);

getAllErrors:
SELECT *
FROM libraryUpdateError;

insert:
INSERT INTO libraryUpdateError(manga_id, message_id, last_update) VALUES (:mangaId, :messageId, strftime('%s', 'now'));

upsert:
INSERT INTO libraryUpdateError(manga_id, message_id, last_update)
VALUES (:mangaId, :messageId, strftime('%s', 'now'))
ON CONFLICT(manga_id)
DO UPDATE
SET
    message_id = :messageId,
    last_update = strftime('%s', 'now')
WHERE manga_id = :mangaId;

deleteAllErrors:
DELETE FROM libraryUpdateError;

deleteErrors:
DELETE FROM libraryUpdateError
WHERE _id IN :_ids;

deleteMangaErrors:
DELETE FROM libraryUpdateError
WHERE manga_id IN :mangaIds;

cleanUnrelevantMangaErrors:
DELETE FROM libraryUpdateError
WHERE NOT EXISTS (
    SELECT 1
    FROM mangas
    WHERE libraryUpdateError.manga_id = mangas._id
    AND mangas.favorite == 1
);
