Add Migration
This commit is contained in:
parent
241e51015f
commit
177329abcf
|
@ -124,7 +124,7 @@ class ActiveServerProvider(
|
||||||
UApp.applicationContext(),
|
UApp.applicationContext(),
|
||||||
MetaDatabase::class.java,
|
MetaDatabase::class.java,
|
||||||
METADATA_DB + serverId
|
METADATA_DB + serverId
|
||||||
).fallbackToDestructiveMigration()
|
).fallbackToDestructiveMigrationOnDowngrade()
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package org.moire.ultrasonic.data
|
package org.moire.ultrasonic.data
|
||||||
|
|
||||||
|
import androidx.room.AutoMigration
|
||||||
import androidx.room.Database
|
import androidx.room.Database
|
||||||
import androidx.room.RoomDatabase
|
import androidx.room.RoomDatabase
|
||||||
import androidx.room.TypeConverter
|
import androidx.room.TypeConverter
|
||||||
import androidx.room.TypeConverters
|
import androidx.room.TypeConverters
|
||||||
import androidx.room.migration.Migration
|
|
||||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import org.moire.ultrasonic.domain.Album
|
import org.moire.ultrasonic.domain.Album
|
||||||
import org.moire.ultrasonic.domain.Artist
|
import org.moire.ultrasonic.domain.Artist
|
||||||
|
@ -25,8 +24,14 @@ import org.moire.ultrasonic.domain.Track
|
||||||
Index::class,
|
Index::class,
|
||||||
MusicFolder::class
|
MusicFolder::class
|
||||||
],
|
],
|
||||||
version = 2,
|
autoMigrations = [
|
||||||
exportSchema = true
|
AutoMigration(
|
||||||
|
from = 1,
|
||||||
|
to = 2
|
||||||
|
),
|
||||||
|
],
|
||||||
|
exportSchema = true,
|
||||||
|
version = 2
|
||||||
)
|
)
|
||||||
@TypeConverters(Converters::class)
|
@TypeConverters(Converters::class)
|
||||||
abstract class MetaDatabase : RoomDatabase() {
|
abstract class MetaDatabase : RoomDatabase() {
|
||||||
|
@ -34,7 +39,7 @@ abstract class MetaDatabase : RoomDatabase() {
|
||||||
|
|
||||||
abstract fun albumDao(): AlbumDao
|
abstract fun albumDao(): AlbumDao
|
||||||
|
|
||||||
abstract fun trackDao(): AlbumDao
|
abstract fun trackDao(): TrackDao
|
||||||
|
|
||||||
abstract fun musicFoldersDao(): MusicFoldersDao
|
abstract fun musicFoldersDao(): MusicFoldersDao
|
||||||
|
|
||||||
|
@ -52,11 +57,3 @@ class Converters {
|
||||||
return date?.time
|
return date?.time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val META_MIGRATION_2_1: Migration = object : Migration(2, 1) {
|
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
|
||||||
database.execSQL(
|
|
||||||
"DROP TABLE ServerSetting"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue