ALTER TABLE libraryUpdateError
ADD COLUMN last_update INTEGER NOT NULL DEFAULT 0;

DROP VIEW IF EXISTS libraryUpdateErrorView;

CREATE VIEW libraryUpdateErrorView AS
SELECT
    mangas._id AS mangaId,
    mangas.title AS mangaTitle,
    mangas.source,
    mangas.favorite,
    mangas.thumbnail_url AS thumbnailUrl,
    mangas.cover_last_modified AS coverLastModified,
    libraryUpdateError._id AS errorId,
    libraryUpdateError.message_id AS messageId,
    libraryUpdateError.last_update AS lastUpdate
FROM mangas JOIN libraryUpdateError
ON mangas._id = libraryUpdateError.manga_id
WHERE favorite = 1
ORDER BY lastUpdate DESC;
