From 83f4452aacf1663ed0a21044d5fa2e3b43dc28d1 Mon Sep 17 00:00:00 2001 From: xuxinchao Date: Wed, 30 Oct 2024 10:27:54 +0800 Subject: [PATCH] =?UTF-8?q?[6.7.2]=E6=95=B0=E6=8D=AE=E5=BA=93=E5=8D=87?= =?UTF-8?q?=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mogo/eagle/core/function/takeover/db/RecordDb.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDb.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDb.kt index 8abcecddb9..1951a81829 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDb.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/takeover/db/RecordDb.kt @@ -4,11 +4,13 @@ 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 /** * 接管记录数据库 */ -@Database(entities = [RecordInfo::class], version = 1, exportSchema = false) +@Database(entities = [RecordInfo::class], version = 2, exportSchema = false) abstract class RecordDb: RoomDatabase() { abstract fun recordDao(): RecordDao @@ -18,10 +20,17 @@ abstract class RecordDb: RoomDatabase() { private var db: RecordDb? = null + private val Migration_One_Two = object : Migration(1, 2) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("ALTER TABLE take_over_record ADD COLUMN bagId INTEGER") + } + } + @JvmStatic fun getDb(context: Context): RecordDb { if (db == null) { db = Room.databaseBuilder(context.applicationContext, RecordDb::class.java, RECORD_DB_NAME) + .addMigrations(Migration_One_Two) .fallbackToDestructiveMigration() .build() }