From 21cc0b97bc7debd194fa5c567e5fe572057dd984 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 10 Feb 2020 22:02:58 +0100 Subject: [PATCH] properly update the database by adding the new sort_value column --- .../gallery/pro/databases/GalleryDatabase.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt index 690ce2fe5..aef29c659 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/databases/GalleryDatabase.kt @@ -9,7 +9,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase import com.simplemobiletools.gallery.pro.interfaces.* import com.simplemobiletools.gallery.pro.models.* -@Database(entities = [Directory::class, Medium::class, Widget::class, DateTaken::class, Favorite::class], version = 7) +@Database(entities = [Directory::class, Medium::class, Widget::class, DateTaken::class, Favorite::class], version = 8) abstract class GalleryDatabase : RoomDatabase() { abstract fun DirectoryDao(): DirectoryDao @@ -34,6 +34,7 @@ abstract class GalleryDatabase : RoomDatabase() { .addMigrations(MIGRATION_4_5) .addMigrations(MIGRATION_5_6) .addMigrations(MIGRATION_6_7) + .addMigrations(MIGRATION_7_8) .build() } } @@ -67,5 +68,11 @@ abstract class GalleryDatabase : RoomDatabase() { database.execSQL("CREATE UNIQUE INDEX `index_favorites_full_path` ON `favorites` (`full_path`)") } } + + private val MIGRATION_7_8 = object : Migration(7, 8) { + override fun migrate(database: SupportSQLiteDatabase) { + database.execSQL("ALTER TABLE directories ADD COLUMN sort_value TEXT NOT NULL") + } + } } }