fix: add database migrations for isShort in watchHistoryItem

This commit is contained in:
Bnyro 2023-11-15 17:14:14 +01:00
parent d1cb212e98
commit 2759121036
2 changed files with 11 additions and 3 deletions

View File

@ -39,7 +39,7 @@ import com.github.libretube.db.obj.WatchPosition
DownloadItem::class, DownloadItem::class,
SubscriptionGroup::class SubscriptionGroup::class
], ],
version = 15, version = 16,
autoMigrations = [ autoMigrations = [
AutoMigration(from = 7, to = 8), AutoMigration(from = 7, to = 8),
AutoMigration(from = 8, to = 9), AutoMigration(from = 8, to = 9),

View File

@ -35,14 +35,22 @@ object DatabaseHolder {
private val MIGRATION_14_15 = object : Migration(14, 15) { private val MIGRATION_14_15 = object : Migration(14, 15) {
override fun migrate(database: SupportSQLiteDatabase) { override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL( database.execSQL(
"ALTER TABLE 'downloaditem' ADD COLUMN 'language' TEXT DEFAULT NULL" "ALTER TABLE 'downloadItem' ADD COLUMN 'language' TEXT DEFAULT NULL"
)
}
}
private val MIGRATION_15_16 = object : Migration(15, 16) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
"ALTER TABLE 'watchHistoryItem' ADD COLUMN 'isShort' INTEGER NOT NULL DEFAULT 0"
) )
} }
} }
val Database by lazy { val Database by lazy {
Room.databaseBuilder(LibreTubeApp.instance, AppDatabase::class.java, DATABASE_NAME) Room.databaseBuilder(LibreTubeApp.instance, AppDatabase::class.java, DATABASE_NAME)
.addMigrations(MIGRATION_11_12, MIGRATION_12_13, MIGRATION_13_14, MIGRATION_14_15) .addMigrations(MIGRATION_11_12, MIGRATION_12_13, MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16)
.fallbackToDestructiveMigration() .fallbackToDestructiveMigration()
.build() .build()
} }