diff --git a/app/src/main/java/com/topjohnwu/magisk/core/data/SuLogDao.kt b/app/src/main/java/com/topjohnwu/magisk/core/data/SuLogDao.kt index 1f39177bc..8b1fe7ddb 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/data/SuLogDao.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/data/SuLogDao.kt @@ -1,6 +1,8 @@ package com.topjohnwu.magisk.core.data import androidx.room.* +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase import com.topjohnwu.magisk.core.model.su.SuLog import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext @@ -10,6 +12,16 @@ import java.util.* abstract class SuLogDatabase : RoomDatabase() { abstract fun suLogDao(): SuLogDao + + companion object { + val MIGRATION_1_2 = object : Migration(1, 2) { + override fun migrate(database: SupportSQLiteDatabase) = with(database) { + execSQL("ALTER TABLE logs ADD COLUMN target INTEGER NOT NULL DEFAULT -1") + execSQL("ALTER TABLE logs ADD COLUMN context TEXT NOT NULL DEFAULT ''") + execSQL("ALTER TABLE logs ADD COLUMN gids TEXT NOT NULL DEFAULT ''") + } + } + } } @Dao diff --git a/app/src/main/java/com/topjohnwu/magisk/core/di/ServiceLocator.kt b/app/src/main/java/com/topjohnwu/magisk/core/di/ServiceLocator.kt index 9ea4e8f45..4bb66ff26 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/di/ServiceLocator.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/di/ServiceLocator.kt @@ -47,6 +47,7 @@ object ServiceLocator { private fun createSuLogDatabase(context: Context) = Room.databaseBuilder(context, SuLogDatabase::class.java, "sulogs.db") + .addMigrations(SuLogDatabase.MIGRATION_1_2) .fallbackToDestructiveMigration() .build()