Add missing name column
This commit is contained in:
parent
46f2f47cda
commit
4e681234fd
@ -8,6 +8,7 @@ import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import androidx.room.TypeConverters
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import de.mm20.launcher2.database.daos.ThemeDao
|
||||
import de.mm20.launcher2.database.entities.CurrencyEntity
|
||||
import de.mm20.launcher2.database.entities.CustomAttributeEntity
|
||||
import de.mm20.launcher2.database.entities.ForecastEntity
|
||||
@ -66,6 +67,8 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
abstract fun searchActionDao(): SearchActionDao
|
||||
|
||||
abstract fun themeDao(): ThemeDao
|
||||
|
||||
companion object {
|
||||
private var _instance: AppDatabase? = null
|
||||
fun getInstance(context: Context): AppDatabase {
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package de.mm20.launcher2.database.daos
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.Query
|
||||
import androidx.room.Update
|
||||
import de.mm20.launcher2.database.entities.ThemeEntity
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import java.util.UUID
|
||||
|
||||
@Dao
|
||||
interface ThemeDao {
|
||||
@Query("SELECT * FROM Theme")
|
||||
fun getAll(): Flow<List<ThemeEntity>>
|
||||
|
||||
@Query("SELECT * FROM Theme WHERE id = :id LIMIT 1")
|
||||
fun get(id: UUID): Flow<ThemeEntity?>
|
||||
|
||||
@Insert
|
||||
suspend fun insert(theme: ThemeEntity)
|
||||
|
||||
@Update
|
||||
suspend fun update(theme: ThemeEntity)
|
||||
|
||||
@Query("DELETE FROM Theme WHERE id = :id")
|
||||
suspend fun delete(id: UUID)
|
||||
}
|
||||
@ -7,6 +7,8 @@ import java.util.UUID
|
||||
@Entity(tableName = "Theme")
|
||||
data class ThemeEntity(
|
||||
@PrimaryKey val id: UUID,
|
||||
val name: String,
|
||||
|
||||
val corePaletteA1: Int?,
|
||||
val corePaletteA2: Int?,
|
||||
val corePaletteA3: Int?,
|
||||
|
||||
@ -3,6 +3,7 @@ package de.mm20.launcher2.database.migrations
|
||||
import android.content.Context
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import de.mm20.launcher2.database.R
|
||||
import de.mm20.launcher2.ktx.toBytes
|
||||
import de.mm20.launcher2.preferences.LauncherDataStore
|
||||
import kotlinx.coroutines.flow.first
|
||||
@ -22,6 +23,8 @@ class Migration_24_25(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS `Theme` (
|
||||
`id` BLOB NOT NULL,
|
||||
`name` TEXT NOT NULL,
|
||||
|
||||
`corePaletteA1` INTEGER,
|
||||
`corePaletteA2` INTEGER,
|
||||
`corePaletteA3` INTEGER,
|
||||
@ -119,11 +122,12 @@ class Migration_24_25(
|
||||
?,?,?,?,?,?,?,?,?,?,
|
||||
?,?,?,?,?,?,?,?,?,?,
|
||||
?,?,?,?,?,?,?,?,?,?,
|
||||
?,?,?,?,?,?,?,?,?
|
||||
?,?,?,?,?,?,?,?,?,?
|
||||
)
|
||||
""".trimIndent(),
|
||||
arrayOf(
|
||||
uuid.toBytes(),
|
||||
context.getString(R.string.preference_colors_custom),
|
||||
customColors.baseColors.accent1.toHexColor(),
|
||||
customColors.baseColors.accent2.toHexColor(),
|
||||
customColors.baseColors.accent3.toHexColor(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user