forked from starfish23/mangafeed
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
13 changed files
with
139 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters