mirror of
https://github.com/mihonapp/mihon.git
synced 2024-10-24 21:12:35 -04:00
38 lines
859 B
Text
38 lines
859 B
Text
|
import java.util.Date;
|
||
|
|
||
|
CREATE TABLE history(
|
||
|
history_id INTEGER NOT NULL PRIMARY KEY,
|
||
|
history_chapter_id INTEGER NOT NULL UNIQUE,
|
||
|
history_last_read INTEGER AS Date,
|
||
|
history_time_read INTEGER AS Date,
|
||
|
FOREIGN KEY(history_chapter_id) REFERENCES chapters (_id)
|
||
|
ON DELETE CASCADE
|
||
|
);
|
||
|
|
||
|
CREATE INDEX history_history_chapter_id_index ON history(history_chapter_id);
|
||
|
|
||
|
resetHistoryById:
|
||
|
UPDATE history
|
||
|
SET history_last_read = 0
|
||
|
WHERE history_id = :historyId;
|
||
|
|
||
|
resetHistoryByMangaId:
|
||
|
UPDATE history
|
||
|
SET history_last_read = 0
|
||
|
WHERE history_id IN (
|
||
|
SELECT H.history_id
|
||
|
FROM mangas M
|
||
|
INNER JOIN chapters C
|
||
|
ON M._id = C.manga_id
|
||
|
INNER JOIN history H
|
||
|
ON C._id = H.history_chapter_id
|
||
|
WHERE M._id = :mangaId
|
||
|
);
|
||
|
|
||
|
removeAllHistory:
|
||
|
DELETE FROM history;
|
||
|
|
||
|
removeResettedHistory:
|
||
|
DELETE FROM history
|
||
|
WHERE history_last_read = 0;
|