[Android] DB migration

Nicolas Pomepuy git at videolan.org
Thu Nov 28 11:41:10 CET 2019


vlc-android | branch: master | Nicolas Pomepuy <nicolas.pomepuy at gmail.com> | Wed Nov 27 13:25:09 2019 +0100| [2d52b1a14cd8a1622f6d5759bf8c2408b9d08502] | committer: Geoffrey Métais

DB migration

> https://code.videolan.org/videolan/vlc-android/commit/2d52b1a14cd8a1622f6d5759bf8c2408b9d08502
---

 vlc-android/src/org/videolan/vlc/database/Migrations.kt | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/database/Migrations.kt b/vlc-android/src/org/videolan/vlc/database/Migrations.kt
index 7e6234424..c32ab85e8 100644
--- a/vlc-android/src/org/videolan/vlc/database/Migrations.kt
+++ b/vlc-android/src/org/videolan/vlc/database/Migrations.kt
@@ -44,6 +44,9 @@ private const val SLAVES_TABLE_NAME = "SLAVES_table"
 private const val FAV_TABLE_NAME = "fav_table"
 private const val CUSTOM_DIRECTORY_TABLE_NAME = "CustomDirectory"
 private const val MEDIA_METADATA_TABLE_NAME = "media_metadata"
+private const val MEDIA_METADATA_IMAGE_TABLE_NAME = "media_metadata_image"
+private const val MEDIA_METADATA_PERSON_TABLE_NAME = "media_metadata_person"
+private const val MEDIA_METADATA_PERSON_JOIN_TABLE_NAME = "media_person_join"
 
 fun dropUnnecessaryTables(database: SupportSQLiteDatabase) {
     database.execSQL("DROP TABLE IF EXISTS $DIR_TABLE_NAME;")
@@ -207,7 +210,10 @@ val migration_28_29 = object:Migration(28, 29) {
 val migration_29_30 = object : Migration(29, 30) {
     override fun migrate(database: SupportSQLiteDatabase) {
         // Drop old External Subtitle Table
-        database.execSQL("CREATE TABLE IF NOT EXISTS `${MEDIA_METADATA_TABLE_NAME}` (`ml_id` INTEGER NOT NULL, `type` INTEGER NOT NULL, `title` TEXT NOT NULL, `summary` TEXT NOT NULL, `date` INTEGER, PRIMARY KEY(`ml_id`))")
+        database.execSQL("CREATE TABLE `${MEDIA_METADATA_TABLE_NAME}` (`moviepedia_id` TEXT NOT NULL, `ml_id` INTEGER, `type` INTEGER NOT NULL, `title` TEXT NOT NULL, `summary` TEXT NOT NULL, `genres` TEXT NOT NULL, `releaseDate` INTEGER, `countries` TEXT NOT NULL, `season` INTEGER, `episode` INTEGER, `current_poster` TEXT NOT NULL, `current_backdrop` TEXT NOT NULL, `show_id` TEXT, `has_cast` INTEGER NOT NULL, `insertDate` INTEGER NOT NULL, PRIMARY KEY(`moviepedia_id`), FOREIGN KEY(`show_id`) REFERENCES `media_metadata`(`moviepedia_id`) ON UPDATE NO ACTION ON DELETE NO ACTION )")
+        database.execSQL("CREATE TABLE `${MEDIA_METADATA_IMAGE_TABLE_NAME}` (`url` TEXT NOT NULL, `media_id` TEXT NOT NULL, `image_type` INTEGER NOT NULL, `image_language` TEXT NOT NULL, PRIMARY KEY(`url`, `media_id`), FOREIGN KEY(`media_id`) REFERENCES `media_metadata`(`moviepedia_id`) ON UPDATE NO ACTION ON DELETE NO ACTION )")
+        database.execSQL("CREATE TABLE `${MEDIA_METADATA_PERSON_TABLE_NAME}` (`moviepedia_id` TEXT NOT NULL, `name` TEXT NOT NULL, `image` TEXT, PRIMARY KEY(`moviepedia_id`))")
+        database.execSQL("CREATE TABLE `${MEDIA_METADATA_PERSON_JOIN_TABLE_NAME}` (`mediaId` TEXT NOT NULL, `personId` TEXT NOT NULL, `type` INTEGER NOT NULL, PRIMARY KEY(`mediaId`, `personId`, `type`), FOREIGN KEY(`mediaId`) REFERENCES `media_metadata`(`moviepedia_id`) ON UPDATE NO ACTION ON DELETE NO ACTION , FOREIGN KEY(`personId`) REFERENCES `media_metadata_person`(`moviepedia_id`) ON UPDATE NO ACTION ON DELETE NO ACTION )")
     }
 }
 



More information about the Android mailing list