From 234f74aa0dab380a634ccb6d2bde4c624e05781b Mon Sep 17 00:00:00 2001 From: Koitharu Date: Tue, 25 Jul 2023 12:28:50 +0300 Subject: [PATCH] Fix database migrations --- .../java/org/koitharu/kotatsu/core/db/MangaDatabaseTest.kt | 2 +- .../koitharu/kotatsu/core/db/migrations/Migration13To14.kt | 2 ++ .../koitharu/kotatsu/core/db/migrations/Migration14To15.kt | 5 +---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/androidTest/java/org/koitharu/kotatsu/core/db/MangaDatabaseTest.kt b/app/src/androidTest/java/org/koitharu/kotatsu/core/db/MangaDatabaseTest.kt index a24d22ca3..523da54c1 100644 --- a/app/src/androidTest/java/org/koitharu/kotatsu/core/db/MangaDatabaseTest.kt +++ b/app/src/androidTest/java/org/koitharu/kotatsu/core/db/MangaDatabaseTest.kt @@ -17,7 +17,7 @@ class MangaDatabaseTest { MangaDatabase::class.java, ) - private val migrations = getDatabaseMigrations() + private val migrations = getDatabaseMigrations(InstrumentationRegistry.getInstrumentation().targetContext) @Test fun versions() { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration13To14.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration13To14.kt index 204e20843..9bd66a08e 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration13To14.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration13To14.kt @@ -9,5 +9,7 @@ class Migration13To14 : Migration(13, 14) { database.execSQL("ALTER TABLE favourite_categories ADD COLUMN `deleted_at` INTEGER NOT NULL DEFAULT 0") database.execSQL("ALTER TABLE favourites ADD COLUMN `deleted_at` INTEGER NOT NULL DEFAULT 0") database.execSQL("ALTER TABLE history ADD COLUMN `deleted_at` INTEGER NOT NULL DEFAULT 0") + database.execSQL("ALTER TABLE preferences ADD COLUMN `cf_brightness` REAL NOT NULL DEFAULT 0") + database.execSQL("ALTER TABLE preferences ADD COLUMN `cf_contrast` REAL NOT NULL DEFAULT 0") } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration14To15.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration14To15.kt index 3dda50a12..7007851d0 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration14To15.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration14To15.kt @@ -5,8 +5,5 @@ import androidx.sqlite.db.SupportSQLiteDatabase class Migration14To15 : Migration(14, 15) { - override fun migrate(database: SupportSQLiteDatabase) { - database.execSQL("ALTER TABLE preferences ADD COLUMN `cf_brightness` REAL NOT NULL DEFAULT 0") - database.execSQL("ALTER TABLE preferences ADD COLUMN `cf_contrast` REAL NOT NULL DEFAULT 0") - } + override fun migrate(database: SupportSQLiteDatabase) = Unit }