From 8d00ff1b4055f469070dbfe3fe4bba326431ce43 Mon Sep 17 00:00:00 2001 From: Jobobby04 Date: Wed, 19 Jul 2023 22:02:06 -0400 Subject: [PATCH] Fix fresh database installs (cherry picked from commit 70bbede29e0f995436d86f50ab14ace837839a6c) --- data/build.gradle.kts | 1 + data/src/main/sqldelight/tachiyomi/data/chapters.sq | 2 +- data/src/main/sqldelight/tachiyomi/data/mangas.sq | 4 ++-- data/src/main/sqldelight/tachiyomi/data/mangas_categories.sq | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/data/build.gradle.kts b/data/build.gradle.kts index c0deab2a04..19e5281f08 100644 --- a/data/build.gradle.kts +++ b/data/build.gradle.kts @@ -16,6 +16,7 @@ android { database("Database") { packageName = "tachiyomi.data" dialect = "sqlite:3.24" + schemaOutputDirectory = project.file("./src/main/sqldelight") } } } diff --git a/data/src/main/sqldelight/tachiyomi/data/chapters.sq b/data/src/main/sqldelight/tachiyomi/data/chapters.sq index d5babe203d..e88cd377cb 100644 --- a/data/src/main/sqldelight/tachiyomi/data/chapters.sq +++ b/data/src/main/sqldelight/tachiyomi/data/chapters.sq @@ -11,7 +11,7 @@ CREATE TABLE chapters( source_order INTEGER NOT NULL, date_fetch INTEGER AS Long NOT NULL, date_upload INTEGER AS Long NOT NULL, - last_modified_at INTEGER AS Long NOT NULL, + last_modified_at INTEGER AS Long NOT NULL DEFAULT 0, FOREIGN KEY(manga_id) REFERENCES mangas (_id) ON DELETE CASCADE ); diff --git a/data/src/main/sqldelight/tachiyomi/data/mangas.sq b/data/src/main/sqldelight/tachiyomi/data/mangas.sq index 1ed66298f7..1f57060cb9 100644 --- a/data/src/main/sqldelight/tachiyomi/data/mangas.sq +++ b/data/src/main/sqldelight/tachiyomi/data/mangas.sq @@ -23,14 +23,14 @@ CREATE TABLE mangas( date_added INTEGER AS Long NOT NULL, update_strategy INTEGER AS UpdateStrategy NOT NULL DEFAULT 0, calculate_interval INTEGER DEFAULT 0 NOT NULL, - last_modified_at INTEGER AS Long NOT NULL, + last_modified_at INTEGER AS Long NOT NULL DEFAULT 0, favorite_modified_at INTEGER AS Long ); CREATE INDEX library_favorite_index ON mangas(favorite) WHERE favorite = 1; CREATE INDEX mangas_url_index ON mangas(url); -CREATE TRIGGER update_favorite_modified_at_mangas +CREATE TRIGGER update_last_favorited_at_mangas AFTER UPDATE OF favorite ON mangas BEGIN UPDATE mangas diff --git a/data/src/main/sqldelight/tachiyomi/data/mangas_categories.sq b/data/src/main/sqldelight/tachiyomi/data/mangas_categories.sq index c10387a6a3..b3082d3a1e 100644 --- a/data/src/main/sqldelight/tachiyomi/data/mangas_categories.sq +++ b/data/src/main/sqldelight/tachiyomi/data/mangas_categories.sq @@ -2,7 +2,7 @@ CREATE TABLE mangas_categories( _id INTEGER NOT NULL PRIMARY KEY, manga_id INTEGER NOT NULL, category_id INTEGER NOT NULL, - last_modified_at INTEGER AS Long NOT NULL, + last_modified_at INTEGER AS Long NOT NULL DEFAULT 0, FOREIGN KEY(category_id) REFERENCES categories (_id) ON DELETE CASCADE, FOREIGN KEY(manga_id) REFERENCES mangas (_id)