[Android] Migrate subtitles DB
Nicolas Pomepuy
git at videolan.org
Thu Nov 21 13:19:10 UTC 2024
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Thu Oct 24 13:42:33 2024 +0200| [3ead16568c632694e94d677fc5e25ff57169bdc7] | committer: Duncan McNamara
Migrate subtitles DB
> https://code.videolan.org/videolan/vlc-android/commit/3ead16568c632694e94d677fc5e25ff57169bdc7
---
.../src/main/java/org/videolan/vlc/database/MediaDatabase.kt | 4 ++--
.../mediadb/src/main/java/org/videolan/vlc/database/Migrations.kt | 7 +++++++
.../src/main/java/org/videolan/vlc/mediadb/models/ExternalSub.kt | 2 ++
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/application/mediadb/src/main/java/org/videolan/vlc/database/MediaDatabase.kt b/application/mediadb/src/main/java/org/videolan/vlc/database/MediaDatabase.kt
index 6780022ff9..18a90f78cc 100644
--- a/application/mediadb/src/main/java/org/videolan/vlc/database/MediaDatabase.kt
+++ b/application/mediadb/src/main/java/org/videolan/vlc/database/MediaDatabase.kt
@@ -33,7 +33,7 @@ import org.videolan.vlc.mediadb.models.*
private const val DB_NAME = "vlc_database"
- at Database(entities = [ExternalSub::class, Slave::class, BrowserFav::class, CustomDirectory::class, Widget::class], version = 35, exportSchema = false)
+ at 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) }
})
diff --git a/application/mediadb/src/main/java/org/videolan/vlc/database/Migrations.kt b/application/mediadb/src/main/java/org/videolan/vlc/database/Migrations.kt
index 5bea85a2bb..ea19c43c86 100644
--- a/application/mediadb/src/main/java/org/videolan/vlc/database/Migrations.kt
+++ b/application/mediadb/src/main/java/org/videolan/vlc/database/Migrations.kt
@@ -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) {
diff --git a/application/mediadb/src/main/java/org/videolan/vlc/mediadb/models/ExternalSub.kt b/application/mediadb/src/main/java/org/videolan/vlc/mediadb/models/ExternalSub.kt
index 35a9d4ff38..998b9ff3bf 100644
--- a/application/mediadb/src/main/java/org/videolan/vlc/mediadb/models/ExternalSub.kt
+++ b/application/mediadb/src/main/java/org/videolan/vlc/mediadb/models/ExternalSub.kt
@@ -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
)
More information about the Android
mailing list