refactor(db): Migrate track queries (that can be migrated) to SQLDelight

This commit is contained in:
Ahmad Ansori Palembani 2024-11-29 18:02:45 +07:00
parent 93ec13f324
commit 726613e6d7
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
14 changed files with 98 additions and 40 deletions

View file

@ -1,5 +1,3 @@
import kotlin.Float;
CREATE TABLE manga_sync(
_id INTEGER NOT NULL PRIMARY KEY,
manga_id INTEGER NOT NULL,
@ -27,3 +25,24 @@ WHERE manga_id = :mangaId;
deleteForManga:
DELETE FROM manga_sync
WHERE manga_id = :mangaId AND sync_id = :syncId;
insert:
INSERT INTO manga_sync(manga_id, sync_id, remote_id, library_id, title, last_chapter_read, total_chapters, status, score, remote_url, start_date, finish_date)
VALUES(:mangaId, :syncId, :remoteId, :libraryId, :title, :lastChapterRead, :totalChapters, :status, :score, :remoteUrl, :startDate, :finishDate);
update:
UPDATE manga_sync
SET
manga_id = coalesce(:mangaId, manga_id),
sync_id = coalesce(:syncId, sync_id),
remote_id = coalesce(:remoteId, remote_id),
library_id = coalesce(:libraryId, library_id),
title = coalesce(:title, title),
last_chapter_read = coalesce(:lastChapterRead, last_chapter_read),
total_chapters = coalesce(:totalChapters, total_chapters),
status = coalesce(:status, status),
score = coalesce(:score, score),
remote_url = coalesce(:remoteUrl, remote_url),
start_date = coalesce(:startDate, start_date),
finish_date = coalesce(:finishDate, finish_date)
WHERE _id = :id;