Apply migration when import DB as well
This commit is contained in:
1 parent
9a3b91c610
commit
b62dd1fcac
2 files changed
+5
-2
No files matched your search
@@ -27,6 +27,7 @@ import com.hippo.ehviewer.dao.BasicDao
|
||||
import com.hippo.ehviewer.dao.DownloadDirname
|
||||
import com.hippo.ehviewer.dao.DownloadInfo
|
||||
import com.hippo.ehviewer.dao.DownloadLabel
|
||||
import com.hippo.ehviewer.dao.EHDB_MIGRATION_4_5
|
||||
import com.hippo.ehviewer.dao.EhDatabase
|
||||
import com.hippo.ehviewer.dao.Filter
|
||||
import com.hippo.ehviewer.dao.HistoryInfo
|
||||
@@ -399,7 +400,9 @@ object EhDB {
|
||||
fun importDB(context: Context, uri: Uri): String? {
|
||||
runCatching {
|
||||
val oldDB = databaseBuilder(context, EhDatabase::class.java, "tmp.db")
|
||||
.createFromInputStream { context.contentResolver.openInputStream(uri) }.build()
|
||||
.createFromInputStream { context.contentResolver.openInputStream(uri) }
|
||||
.addMigrations(EHDB_MIGRATION_4_5)
|
||||
.build()
|
||||
|
||||
// Download label
|
||||
val manager = DownloadManager
|
||||
|
||||
@@ -8,7 +8,7 @@ import androidx.room.RoomDatabase
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
private val EHDB_MIGRATION_4_5 = object : Migration(4, 5) {
|
||||
val EHDB_MIGRATION_4_5 = object : Migration(4, 5) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
val needMigrationTables = arrayOf(
|
||||
"DOWNLOADS",
|
||||
|
||||
Reference in new issue
Block a user