Database changes to support library syncing (#9683)
* feat: added migrations. * feat: create triggers, account for new installs. * feat: update mappers to include the new field. * feat: update backupManga and backupChapter. Include the new fields to be backed up as well. * feat: add sql query to fetch all manga with `last_favorited_at` field. * feat: version bump. * chore: revert and refactor. * chore: forgot to lower case the field name. * chore: added getAllManga query as well renamed `fetchMangaWithLastFavorite` to `getMangasWithFavoriteTimestamp` * chore: oops that's not meant to be there. * feat: back fill and set last_modified_at to not null. * chore: remove redundant triggers. * fix: build error, accidentally removed insert. * fix: build error, accidentally removed insert. * refactor: review pointer, make fields not null.pull/9700/head
parent
d0f52ea93d
commit
a577f5534f
@ -0,0 +1,49 @@
|
|||||||
|
ALTER TABLE mangas ADD COLUMN last_modified_at INTEGER AS Long NOT NULL;
|
||||||
|
ALTER TABLE mangas ADD COLUMN favorite_modified_at INTEGER AS Long;
|
||||||
|
ALTER TABLE mangas_categories ADD COLUMN last_modified_at INTEGER AS Long NOT NULL;
|
||||||
|
ALTER TABLE chapters ADD COLUMN last_modified_at INTEGER AS Long NOT NULL;
|
||||||
|
|
||||||
|
UPDATE mangas SET last_modified_at = strftime('%s', 'now');
|
||||||
|
UPDATE mangas SET favorite_modified_at = strftime('%s', 'now') WHERE favorite = 1;
|
||||||
|
UPDATE mangas_categories SET last_modified_at = strftime('%s', 'now');
|
||||||
|
UPDATE chapters SET last_modified_at = strftime('%s', 'now');
|
||||||
|
|
||||||
|
-- Create triggers
|
||||||
|
DROP TRIGGER IF EXISTS update_last_modified_at_mangas;
|
||||||
|
CREATE TRIGGER update_last_modified_at_mangas
|
||||||
|
AFTER UPDATE ON mangas
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE mangas
|
||||||
|
SET last_modified_at = strftime('%s', 'now')
|
||||||
|
WHERE _id = new._id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS update_favorite_modified_at_mangas;
|
||||||
|
CREATE TRIGGER update_last_favorited_at_mangas
|
||||||
|
AFTER UPDATE OF favorite ON mangas
|
||||||
|
BEGIN
|
||||||
|
UPDATE mangas
|
||||||
|
SET favorite_modified_at = strftime('%s', 'now')
|
||||||
|
WHERE _id = new._id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS update_last_modified_at_chapters;
|
||||||
|
CREATE TRIGGER update_last_modified_at_chapters
|
||||||
|
AFTER UPDATE ON chapters
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE chapters
|
||||||
|
SET last_modified_at = strftime('%s', 'now')
|
||||||
|
WHERE _id = new._id;
|
||||||
|
END;
|
||||||
|
|
||||||
|
DROP TRIGGER IF EXISTS update_last_modified_at_mangas_categories;
|
||||||
|
CREATE TRIGGER update_last_modified_at_mangas_categories
|
||||||
|
AFTER UPDATE ON mangas_categories
|
||||||
|
FOR EACH ROW
|
||||||
|
BEGIN
|
||||||
|
UPDATE mangas_categories
|
||||||
|
SET last_modified_at = strftime('%s', 'now')
|
||||||
|
WHERE _id = new._id;
|
||||||
|
END;
|
Loading…
Reference in new issue