Migrate subtitles DB

This commit is contained in:
Nicolas Pomepuy 2024-10-24 13:42:33 +02:00 committed by Duncan McNamara
parent 520cb0bb43
commit 3ead16568c
3 changed files with 11 additions and 2 deletions

View File

@ -33,7 +33,7 @@ import org.videolan.vlc.mediadb.models.*
private const val DB_NAME = "vlc_database"
@Database(entities = [ExternalSub::class, Slave::class, BrowserFav::class, CustomDirectory::class, Widget::class], version = 35, exportSchema = false)
@Database(entities = [ExternalSub::class, Slave::class, BrowserFav::class, CustomDirectory::class, Widget::class], version = 36, exportSchema = false)
@TypeConverters(Converters::class)
abstract class MediaDatabase: RoomDatabase() {
abstract fun externalSubDao(): ExternalSubDao
@ -55,7 +55,7 @@ private fun buildDatabase(context: Context) = Room.databaseBuilder(context.appli
migration_21_22, migration_22_23, migration_23_24, migration_24_25,
migration_25_26, migration_26_27, migration_27_28, migration_28_29,
migration_29_30, migration_30_31, migration_31_32, migration_32_33,
migration_33_34, migration_34_35)
migration_33_34, migration_34_35, migration_35_36)
.addCallback(object : RoomDatabase.Callback() {
override fun onCreate(db: SupportSQLiteDatabase) { if (!AndroidDevices.isTv) populateDB(context) }
})

View File

@ -253,6 +253,13 @@ val migration_34_35 = object:Migration(34, 35) {
}
}
val migration_35_36 = object:Migration(35, 36) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("ALTER TABLE $EXTERNAL_SUBTITLES_TABLE_NAME ADD COLUMN `hearingImpaired` INTEGER DEFAULT 0 not null")
}
}
@OptIn(DelicateCoroutinesApi::class)
fun populateDB(context: Context) = GlobalScope.launch(Dispatchers.IO) {

View File

@ -20,6 +20,7 @@
package org.videolan.vlc.mediadb.models
import androidx.room.ColumnInfo
import androidx.room.Entity
@Entity(tableName = "external_subtitles_table", primaryKeys = ["mediaPath", "idSubtitle"])
@ -29,5 +30,6 @@ data class ExternalSub (
val mediaPath: String,
val subLanguageID: String,
val movieReleaseName: String,
@ColumnInfo(defaultValue = "0")
val hearingImpaired: Boolean
)