From 9799ae26efb722cd6753387044357ce3d34a968b Mon Sep 17 00:00:00 2001 From: Sayantan Roychowdhury Date: Mon, 15 May 2023 21:00:38 +0530 Subject: [PATCH] add migration rule to delete faulty apps table --- .../foundation/e/apps/api/database/AppDatabase.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/foundation/e/apps/api/database/AppDatabase.kt b/app/src/main/java/foundation/e/apps/api/database/AppDatabase.kt index d52abde04..3816d41f8 100644 --- a/app/src/main/java/foundation/e/apps/api/database/AppDatabase.kt +++ b/app/src/main/java/foundation/e/apps/api/database/AppDatabase.kt @@ -4,6 +4,8 @@ import android.content.Context import androidx.room.Database import androidx.room.Room import androidx.room.RoomDatabase +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase import foundation.e.apps.api.exodus.Tracker import foundation.e.apps.api.exodus.TrackerDao import foundation.e.apps.api.faultyApps.FaultyApp @@ -13,7 +15,7 @@ import foundation.e.apps.api.fdroid.models.FdroidEntity @Database( entities = [Tracker::class, FdroidEntity::class, FaultyApp::class], - version = 3, + version = 4, exportSchema = false ) abstract class AppDatabase : RoomDatabase() { @@ -30,10 +32,17 @@ abstract class AppDatabase : RoomDatabase() { INSTANCE = Room.databaseBuilder(context, AppDatabase::class.java, "App_Lounge") .fallbackToDestructiveMigration() + .addMigrations(migration3To4) .build() } } return INSTANCE } + + private val migration3To4 = object: Migration(3, 4) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("DELETE FROM FaultyApp") + } + } } } -- GitLab