Change Icons schema:

- drop useless `scale` column
- add `themed` column
- add `name` column
This commit is contained in:
MM20
2023-02-14 21:11:09 +01:00
parent ebcd91091d
commit 6407d0577f
6 changed files with 531 additions and 23 deletions

View File

@@ -18,6 +18,7 @@ import de.mm20.launcher2.database.migrations.Migration_15_16
import de.mm20.launcher2.database.migrations.Migration_16_17
import de.mm20.launcher2.database.migrations.Migration_17_18
import de.mm20.launcher2.database.migrations.Migration_18_19
import de.mm20.launcher2.database.migrations.Migration_19_20
import de.mm20.launcher2.database.migrations.Migration_6_7
import de.mm20.launcher2.database.migrations.Migration_7_8
import de.mm20.launcher2.database.migrations.Migration_8_9
@@ -33,7 +34,7 @@ import de.mm20.launcher2.database.migrations.Migration_9_10
WidgetEntity::class,
CustomAttributeEntity::class,
SearchActionEntity::class,
], version = 19, exportSchema = true
], version = 20, exportSchema = true
)
@TypeConverters(ComponentNameConverter::class, StringListConverter::class)
abstract class AppDatabase : RoomDatabase() {
@@ -99,6 +100,7 @@ abstract class AppDatabase : RoomDatabase() {
Migration_16_17(),
Migration_17_18(),
Migration_18_19(),
Migration_19_20(),
).build()
if (_instance == null) _instance = instance
return instance

View File

@@ -10,6 +10,7 @@ data class IconEntity(
val componentName: ComponentName?,
val drawable: String?,
val iconPack: String,
val scale : Float? = null,
val themed: Boolean,
val name: String?,
@PrimaryKey(autoGenerate = true) val id : Long? = null
)

View File

@@ -0,0 +1,22 @@
package de.mm20.launcher2.database.migrations
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
class Migration_19_20: Migration(19, 20) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE `Icons` RENAME TO `Icons_old`")
database.execSQL("""
CREATE TABLE IF NOT EXISTS `Icons` (
`type` TEXT NOT NULL,
`componentName` TEXT,
`drawable` TEXT,
`iconPack` TEXT NOT NULL,
`themed` INTEGER NOT NULL,
`name` TEXT,
`id` INTEGER PRIMARY KEY AUTOINCREMENT)
""")
database.execSQL("INSERT INTO `Icons` (`type`, `componentName`, `drawable`, `iconPack`, `themed`, `name`) SELECT `type`, `componentName`, `drawable`, `iconPack`, 0, null FROM `Icons_old`")
database.execSQL("DROP TABLE `Icons_old`")
}
}