The history does not update the total number of pages in the volume if they are added or deleted.
This corrects the situation:
UPDATE HISTORY SET PAGES_COUNT = NULL;
UPDATE HISTORY
SET PAGES_COUNT =
CASE
WHEN PAGES_COUNT IS NULL AND ARCHIVE_HASH IN (SELECT MANGA_ID FROM BOOK_ARCHIVES)
THEN (SELECT PAGES_COUNT FROM BOOK_ARCHIVES WHERE BOOK_ARCHIVES.MANGA_ID = HISTORY.ARCHIVE_HASH)
WHEN PAGES_COUNT IS NULL AND CHAPTER_HASH IN (SELECT CHAPTER_ID FROM BOOK_CHAPTERS)
THEN (SELECT PAGES_COUNT FROM BOOK_CHAPTERS WHERE BOOK_CHAPTERS.CHAPTER_ID = HISTORY.CHAPTER_HASH)
ELSE PAGES_COUNT
END;
The history does not update the total number of pages in the volume if they are added or deleted.
This corrects the situation: