refactor(db): Migrate GetTrack to SQLDelight

This commit is contained in:
Ahmad Ansori Palembani 2024-11-28 20:53:26 +07:00
parent e9a68f661f
commit c183802096
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
26 changed files with 154 additions and 48 deletions

View file

@ -10,3 +10,8 @@ findAll:
SELECT *
FROM categories
ORDER BY sort;
findAllByMangaId:
SELECT categories.* FROM categories
JOIN mangas_categories ON categories._id = mangas_categories.category_id
WHERE mangas_categories.manga_id = :mangaId;

View file

@ -1,5 +1,4 @@
import kotlin.Float;
import kotlin.Long;
CREATE TABLE manga_sync(
_id INTEGER NOT NULL PRIMARY KEY,
@ -11,11 +10,16 @@ CREATE TABLE manga_sync(
last_chapter_read REAL NOT NULL,
total_chapters INTEGER NOT NULL,
status INTEGER NOT NULL,
score REAL AS Float NOT NULL,
score REAL NOT NULL,
remote_url TEXT NOT NULL,
start_date INTEGER AS Long NOT NULL,
finish_date INTEGER AS Long NOT NULL,
start_date INTEGER NOT NULL,
finish_date INTEGER NOT NULL,
UNIQUE (manga_id, sync_id) ON CONFLICT REPLACE,
FOREIGN KEY(manga_id) REFERENCES mangas (_id)
ON DELETE CASCADE
);
getAllByMangaId:
SELECT *
FROM manga_sync
WHERE manga_id = :mangaId;