ultrasonic-app-subsonic-and.../ultrasonic/src/main/kotlin/org/moire/ultrasonic/data/AppDatabase.kt

53 lines
1.6 KiB
Kotlin
Raw Normal View History

package org.moire.ultrasonic.data
import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
/**
* Room Database to be used to store global data for the whole app.
* This could be settings or data that are not specific to any remote music database
*/
2021-10-14 17:17:32 +02:00
@Database(entities = [ServerSetting::class], version = 4)
abstract class AppDatabase : RoomDatabase() {
/**
* Retrieves the Server Settings DAO for the Database
*/
abstract fun serverSettingDao(): ServerSettingDao
}
val MIGRATION_1_2: Migration = object : Migration(1, 2) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
"ALTER TABLE ServerSetting ADD COLUMN minimumApiVersion TEXT"
)
}
}
2021-05-24 23:25:12 +02:00
val MIGRATION_2_3: Migration = object : Migration(2, 3) {
override fun migrate(database: SupportSQLiteDatabase) {
2021-05-25 18:51:00 +02:00
database.execSQL(
2021-05-29 15:00:46 +02:00
"ALTER TABLE ServerSetting ADD COLUMN chatSupport INTEGER"
2021-05-25 18:51:00 +02:00
)
database.execSQL(
2021-05-29 15:00:46 +02:00
"ALTER TABLE ServerSetting ADD COLUMN bookmarkSupport INTEGER"
2021-05-25 18:51:00 +02:00
)
database.execSQL(
2021-05-29 15:00:46 +02:00
"ALTER TABLE ServerSetting ADD COLUMN shareSupport INTEGER"
2021-05-25 18:51:00 +02:00
)
database.execSQL(
2021-05-29 15:00:46 +02:00
"ALTER TABLE ServerSetting ADD COLUMN podcastSupport INTEGER"
2021-05-25 18:51:00 +02:00
)
2021-05-24 23:25:12 +02:00
}
}
2021-10-14 17:17:32 +02:00
val MIGRATION_3_4: Migration = object : Migration(3, 4) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL(
"ALTER TABLE ServerSetting ADD COLUMN color INTEGER"
)
}
}