Add Migration

This commit is contained in:
tzugen 2022-06-19 13:24:05 +02:00
parent 241e51015f
commit 177329abcf
No known key found for this signature in database
GPG Key ID: 61E9C34BC10EC930
2 changed files with 11 additions and 14 deletions

View File

@ -124,7 +124,7 @@ class ActiveServerProvider(
UApp.applicationContext(),
MetaDatabase::class.java,
METADATA_DB + serverId
).fallbackToDestructiveMigration()
).fallbackToDestructiveMigrationOnDowngrade()
.build()
}

View File

@ -1,11 +1,10 @@
package org.moire.ultrasonic.data
import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.TypeConverter
import androidx.room.TypeConverters
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import java.util.Date
import org.moire.ultrasonic.domain.Album
import org.moire.ultrasonic.domain.Artist
@ -25,8 +24,14 @@ import org.moire.ultrasonic.domain.Track
Index::class,
MusicFolder::class
],
version = 2,
exportSchema = true
autoMigrations = [
AutoMigration(
from = 1,
to = 2
),
],
exportSchema = true,
version = 2
)
@TypeConverters(Converters::class)
abstract class MetaDatabase : RoomDatabase() {
@ -34,7 +39,7 @@ abstract class MetaDatabase : RoomDatabase() {
abstract fun albumDao(): AlbumDao
abstract fun trackDao(): AlbumDao
abstract fun trackDao(): TrackDao
abstract fun musicFoldersDao(): MusicFoldersDao
@ -52,11 +57,3 @@ class Converters {
return date?.time
}
}
val META_MIGRATION_2_1: Migration = object : Migration(2, 1) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
"DROP TABLE ServerSetting"
)
}
}