Migrated all table and column names to lower snake case (#3195)

* Migrated all table names to lower snake case

* Migrated all table names to lower snake case

* Migrated all table names to lower snake case

* Migrated all column names to lower snake case

* Migrated all column names to lower snake case

* Merged the migrations to 1 migration

* Fixed feedback

* Update migration script
This commit is contained in:
Joost Lekkerkerker 2023-01-25 04:30:36 +01:00 committed by GitHub
parent 65696e891b
commit 59fa25ece0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 899 additions and 27 deletions

View file

@ -0,0 +1,773 @@
{
"formatVersion": 1,
"database": {
"version": 37,
"identityHash": "ef7bffe8a27b46fc8303956dd44e7213",
"entities": [
{
"tableName": "sensor_attributes",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sensor_id` TEXT NOT NULL, `name` TEXT NOT NULL, `value` TEXT NOT NULL, `value_type` TEXT NOT NULL, PRIMARY KEY(`sensor_id`, `name`))",
"fields": [
{
"fieldPath": "sensorId",
"columnName": "sensor_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "value",
"columnName": "value",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "valueType",
"columnName": "value_type",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"sensor_id",
"name"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "authentication_list",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`host` TEXT NOT NULL, `username` TEXT NOT NULL, `password` TEXT NOT NULL, PRIMARY KEY(`host`))",
"fields": [
{
"fieldPath": "host",
"columnName": "host",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "username",
"columnName": "username",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "password",
"columnName": "password",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"host"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "sensors",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `registered` INTEGER DEFAULT NULL, `state` TEXT NOT NULL, `last_sent_state` TEXT DEFAULT NULL, `last_sent_icon` TEXT DEFAULT NULL, `state_type` TEXT NOT NULL, `type` TEXT NOT NULL, `icon` TEXT NOT NULL, `name` TEXT NOT NULL, `device_class` TEXT, `unit_of_measurement` TEXT, `state_class` TEXT, `entity_category` TEXT, `core_registration` TEXT, `app_registration` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "enabled",
"columnName": "enabled",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "registered",
"columnName": "registered",
"affinity": "INTEGER",
"notNull": false,
"defaultValue": "NULL"
},
{
"fieldPath": "state",
"columnName": "state",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "lastSentState",
"columnName": "last_sent_state",
"affinity": "TEXT",
"notNull": false,
"defaultValue": "NULL"
},
{
"fieldPath": "lastSentIcon",
"columnName": "last_sent_icon",
"affinity": "TEXT",
"notNull": false,
"defaultValue": "NULL"
},
{
"fieldPath": "stateType",
"columnName": "state_type",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "type",
"columnName": "type",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "icon",
"columnName": "icon",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "deviceClass",
"columnName": "device_class",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "unitOfMeasurement",
"columnName": "unit_of_measurement",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "stateClass",
"columnName": "state_class",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "entityCategory",
"columnName": "entity_category",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "coreRegistration",
"columnName": "core_registration",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "appRegistration",
"columnName": "app_registration",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "sensor_settings",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`sensor_id` TEXT NOT NULL, `name` TEXT NOT NULL, `value` TEXT NOT NULL, `value_type` TEXT NOT NULL, `enabled` INTEGER NOT NULL, `entries` TEXT NOT NULL, PRIMARY KEY(`sensor_id`, `name`))",
"fields": [
{
"fieldPath": "sensorId",
"columnName": "sensor_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "name",
"columnName": "name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "value",
"columnName": "value",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "valueType",
"columnName": "value_type",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "enabled",
"columnName": "enabled",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "entries",
"columnName": "entries",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"sensor_id",
"name"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "button_widgets",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `icon_id` INTEGER NOT NULL, `domain` TEXT NOT NULL, `service` TEXT NOT NULL, `service_data` TEXT NOT NULL, `label` TEXT, `background_type` TEXT NOT NULL DEFAULT 'DAYNIGHT', `text_color` TEXT, `require_authentication` INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "iconId",
"columnName": "icon_id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "domain",
"columnName": "domain",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "service",
"columnName": "service",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "serviceData",
"columnName": "service_data",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "label",
"columnName": "label",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "backgroundType",
"columnName": "background_type",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'DAYNIGHT'"
},
{
"fieldPath": "textColor",
"columnName": "text_color",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "requireAuthentication",
"columnName": "require_authentication",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "camera_widgets",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `entity_id` TEXT NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "entityId",
"columnName": "entity_id",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "media_player_controls_widgets",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `entity_id` TEXT NOT NULL, `label` TEXT, `show_skip` INTEGER NOT NULL, `show_seek` INTEGER NOT NULL, `show_volume` INTEGER NOT NULL, `show_source` INTEGER NOT NULL DEFAULT false, `background_type` TEXT NOT NULL DEFAULT 'DAYNIGHT', `text_color` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "entityId",
"columnName": "entity_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "label",
"columnName": "label",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "showSkip",
"columnName": "show_skip",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "showSeek",
"columnName": "show_seek",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "showVolume",
"columnName": "show_volume",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "showSource",
"columnName": "show_source",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "false"
},
{
"fieldPath": "backgroundType",
"columnName": "background_type",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'DAYNIGHT'"
},
{
"fieldPath": "textColor",
"columnName": "text_color",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "static_widget",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `entity_id` TEXT NOT NULL, `attribute_ids` TEXT, `label` TEXT, `text_size` REAL NOT NULL, `state_separator` TEXT NOT NULL, `attribute_separator` TEXT NOT NULL, `last_update` TEXT NOT NULL, `background_type` TEXT NOT NULL DEFAULT 'DAYNIGHT', `text_color` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "entityId",
"columnName": "entity_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "attributeIds",
"columnName": "attribute_ids",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "label",
"columnName": "label",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "textSize",
"columnName": "text_size",
"affinity": "REAL",
"notNull": true
},
{
"fieldPath": "stateSeparator",
"columnName": "state_separator",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "attributeSeparator",
"columnName": "attribute_separator",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "lastUpdate",
"columnName": "last_update",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "backgroundType",
"columnName": "background_type",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'DAYNIGHT'"
},
{
"fieldPath": "textColor",
"columnName": "text_color",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "template_widgets",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `template` TEXT NOT NULL, `text_size` REAL NOT NULL DEFAULT 12.0, `last_update` TEXT NOT NULL, `background_type` TEXT NOT NULL DEFAULT 'DAYNIGHT', `text_color` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "template",
"columnName": "template",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "textSize",
"columnName": "text_size",
"affinity": "REAL",
"notNull": true,
"defaultValue": "12.0"
},
{
"fieldPath": "lastUpdate",
"columnName": "last_update",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "backgroundType",
"columnName": "background_type",
"affinity": "TEXT",
"notNull": true,
"defaultValue": "'DAYNIGHT'"
},
{
"fieldPath": "textColor",
"columnName": "text_color",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "notification_history",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `received` INTEGER NOT NULL, `message` TEXT NOT NULL, `data` TEXT NOT NULL, `source` TEXT NOT NULL)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "received",
"columnName": "received",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "message",
"columnName": "message",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "data",
"columnName": "data",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "source",
"columnName": "source",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "qs_tiles",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `tile_id` TEXT NOT NULL, `added` INTEGER NOT NULL DEFAULT 1, `icon_id` INTEGER, `entity_id` TEXT NOT NULL, `label` TEXT NOT NULL, `subtitle` TEXT, `should_vibrate` INTEGER NOT NULL DEFAULT 0, `auth_required` INTEGER NOT NULL DEFAULT 0)",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "tileId",
"columnName": "tile_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "added",
"columnName": "added",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "1"
},
{
"fieldPath": "iconId",
"columnName": "icon_id",
"affinity": "INTEGER",
"notNull": false
},
{
"fieldPath": "entityId",
"columnName": "entity_id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "label",
"columnName": "label",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "subtitle",
"columnName": "subtitle",
"affinity": "TEXT",
"notNull": false
},
{
"fieldPath": "shouldVibrate",
"columnName": "should_vibrate",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
},
{
"fieldPath": "authRequired",
"columnName": "auth_required",
"affinity": "INTEGER",
"notNull": true,
"defaultValue": "0"
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": true
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "favorites",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `position` INTEGER NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "position",
"columnName": "position",
"affinity": "INTEGER",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "favorite_cache",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `friendly_name` TEXT NOT NULL, `icon` TEXT, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "friendlyName",
"columnName": "friendly_name",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "icon",
"columnName": "icon",
"affinity": "TEXT",
"notNull": false
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "entity_state_complications",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `entity_id` TEXT NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "entityId",
"columnName": "entity_id",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
},
{
"tableName": "settings",
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER NOT NULL, `websocket_setting` TEXT NOT NULL, `sensor_update_frequency` TEXT NOT NULL, PRIMARY KEY(`id`))",
"fields": [
{
"fieldPath": "id",
"columnName": "id",
"affinity": "INTEGER",
"notNull": true
},
{
"fieldPath": "websocketSetting",
"columnName": "websocket_setting",
"affinity": "TEXT",
"notNull": true
},
{
"fieldPath": "sensorUpdateFrequency",
"columnName": "sensor_update_frequency",
"affinity": "TEXT",
"notNull": true
}
],
"primaryKey": {
"columnNames": [
"id"
],
"autoGenerate": false
},
"indices": [],
"foreignKeys": []
}
],
"views": [],
"setupQueries": [
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ef7bffe8a27b46fc8303956dd44e7213')"
]
}
}

View file

@ -15,6 +15,8 @@ import androidx.core.content.getSystemService
import androidx.room.AutoMigration
import androidx.room.Database
import androidx.room.OnConflictStrategy
import androidx.room.RenameColumn
import androidx.room.RenameTable
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
@ -77,7 +79,7 @@ import io.homeassistant.companion.android.common.R as commonR
EntityStateComplications::class,
Setting::class
],
version = 36,
version = 37,
autoMigrations = [
AutoMigration(from = 24, to = 25),
AutoMigration(from = 25, to = 26),
@ -91,6 +93,7 @@ import io.homeassistant.companion.android.common.R as commonR
AutoMigration(from = 33, to = 34),
AutoMigration(from = 34, to = 35),
AutoMigration(from = 35, to = 36),
AutoMigration(from = 36, to = 37, spec = AppDatabase.Companion.Migration36to37::class),
]
)
@TypeConverters(
@ -275,16 +278,19 @@ abstract class AppDatabase : RoomDatabase() {
database.execSQL("CREATE TABLE IF NOT EXISTS `sensor_attributes` (`sensor_id` TEXT NOT NULL, `name` TEXT NOT NULL, `value` TEXT NOT NULL, PRIMARY KEY(`sensor_id`, `name`))")
}
}
private val MIGRATION_7_8 = object : Migration(7, 8) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE `sensor_attributes` ADD `value_type` TEXT NOT NULL DEFAULT 'string'")
}
}
private val MIGRATION_8_9 = object : Migration(8, 9) {
override fun migrate(database: SupportSQLiteDatabase) {
database.execSQL("ALTER TABLE `sensors` ADD `state_changed` INTEGER NOT NULL DEFAULT ''")
}
}
private val MIGRATION_9_10 = object : Migration(9, 10) {
override fun migrate(database: SupportSQLiteDatabase) {
val cursor = database.query("SELECT * FROM sensors")
@ -527,6 +533,99 @@ abstract class AppDatabase : RoomDatabase() {
}
}
@RenameColumn.Entries(
RenameColumn(
tableName = "Authentication_List",
fromColumnName = "Username",
toColumnName = "username"
),
RenameColumn(
tableName = "Authentication_List",
fromColumnName = "Password",
toColumnName = "password"
),
RenameColumn(
tableName = "qs_tiles",
fromColumnName = "tileId",
toColumnName = "tile_id"
),
RenameColumn(
tableName = "qs_tiles",
fromColumnName = "entityId",
toColumnName = "entity_id"
),
RenameColumn(
tableName = "qs_tiles",
fromColumnName = "shouldVibrate",
toColumnName = "should_vibrate"
),
RenameColumn(
tableName = "qs_tiles",
fromColumnName = "authRequired",
toColumnName = "auth_required"
),
RenameColumn(
tableName = "settings",
fromColumnName = "websocketSetting",
toColumnName = "websocket_setting"
),
RenameColumn(
tableName = "settings",
fromColumnName = "sensorUpdateFrequency",
toColumnName = "sensor_update_frequency"
),
RenameColumn(
tableName = "camera_widgets",
fromColumnName = "entityId",
toColumnName = "entity_id"
),
RenameColumn(
tableName = "entityStateComplications",
fromColumnName = "entityId",
toColumnName = "entity_id"
),
RenameColumn(
tableName = "mediaplayctrls_widgets",
fromColumnName = "entityId",
toColumnName = "entity_id"
),
RenameColumn(
tableName = "mediaplayctrls_widgets",
fromColumnName = "showSkip",
toColumnName = "show_skip"
),
RenameColumn(
tableName = "mediaplayctrls_widgets",
fromColumnName = "showSeek",
toColumnName = "show_seek"
),
RenameColumn(
tableName = "mediaplayctrls_widgets",
fromColumnName = "showVolume",
toColumnName = "show_volume"
),
RenameColumn(
tableName = "mediaplayctrls_widgets",
fromColumnName = "showSource",
toColumnName = "show_source"
)
)
@RenameTable.Entries(
RenameTable(
fromTableName = "Authentication_List",
toTableName = "authentication_list"
),
RenameTable(
fromTableName = "entityStateComplications",
toTableName = "entity_state_complications"
),
RenameTable(
fromTableName = "mediaplayctrls_widgets",
toTableName = "media_player_controls_widgets"
)
)
class Migration36to37 : AutoMigrationSpec
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val notificationManager = appContext.getSystemService<NotificationManager>()!!

View file

@ -4,14 +4,14 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "Authentication_List")
@Entity(tableName = "authentication_list")
data class Authentication(
@PrimaryKey
val host: String,
@ColumnInfo(name = "Username")
@ColumnInfo(name = "username")
val username: String,
@ColumnInfo(name = "Password")
@ColumnInfo(name = "password")
val password: String
)

View file

@ -14,6 +14,6 @@ interface AuthenticationDao {
@Update
fun update(authentication: Authentication)
@Query("SELECT * from Authentication_List WHERE Host = :key")
@Query("SELECT * from authentication_list WHERE Host = :key")
fun get(key: String): Authentication?
}

View file

@ -8,7 +8,7 @@ import androidx.room.Query
@Dao
interface TileDao {
@Query("SELECT * FROM qs_tiles WHERE tileId = :tileId")
@Query("SELECT * FROM qs_tiles WHERE tile_id = :tileId")
suspend fun get(tileId: String): TileEntity?
@Query("SELECT * FROM qs_tiles")

View file

@ -8,21 +8,21 @@ import androidx.room.PrimaryKey
data class TileEntity(
@PrimaryKey(autoGenerate = true)
val id: Int = 0,
@ColumnInfo(name = "tileId")
@ColumnInfo(name = "tile_id")
val tileId: String,
@ColumnInfo(name = "added", defaultValue = "1")
val added: Boolean,
@ColumnInfo(name = "icon_id")
val iconId: Int?,
@ColumnInfo(name = "entityId")
@ColumnInfo(name = "entity_id")
val entityId: String,
@ColumnInfo(name = "label")
val label: String,
@ColumnInfo(name = "subtitle")
val subtitle: String?,
@ColumnInfo(name = "shouldVibrate", defaultValue = "0")
@ColumnInfo(name = "should_vibrate", defaultValue = "0")
val shouldVibrate: Boolean,
@ColumnInfo(name = "authRequired", defaultValue = "0")
@ColumnInfo(name = "auth_required", defaultValue = "0")
val authRequired: Boolean
)

View file

@ -9,8 +9,8 @@ data class Setting(
@PrimaryKey
@ColumnInfo(name = "id")
val id: Int,
@ColumnInfo(name = "websocketSetting")
@ColumnInfo(name = "websocket_setting")
var websocketSetting: WebsocketSetting,
@ColumnInfo(name = "sensorUpdateFrequency")
@ColumnInfo(name = "sensor_update_frequency")
var sensorUpdateFrequency: SensorUpdateFrequencySetting
)

View file

@ -7,11 +7,11 @@ import androidx.room.PrimaryKey
/**
* Represents the configuration of an entity state complication
*/
@Entity(tableName = "entityStateComplications")
@Entity(tableName = "entity_state_complications")
data class EntityStateComplications(
@PrimaryKey
@ColumnInfo(name = "id")
val id: Int,
@ColumnInfo(name = "entityId")
@ColumnInfo(name = "entity_id")
val entityId: String
)

View file

@ -7,7 +7,7 @@ import androidx.room.Query
@Dao
interface EntityStateComplicationsDao {
@Query("SELECT * FROM entityStateComplications WHERE id = :id")
@Query("SELECT * FROM entity_state_complications WHERE id = :id")
suspend fun get(id: Int): EntityStateComplications?
@Insert(onConflict = OnConflictStrategy.REPLACE)

View file

@ -8,6 +8,6 @@ import androidx.room.PrimaryKey
data class CameraWidgetEntity(
@PrimaryKey
override val id: Int,
@ColumnInfo(name = "entityId")
@ColumnInfo(name = "entity_id")
val entityId: String
) : WidgetEntity

View file

@ -9,21 +9,21 @@ import kotlinx.coroutines.flow.Flow
@Dao
interface MediaPlayerControlsWidgetDao : WidgetDao {
@Query("SELECT * FROM mediaplayctrls_widgets WHERE id = :id")
@Query("SELECT * FROM media_player_controls_widgets WHERE id = :id")
fun get(id: Int): MediaPlayerControlsWidgetEntity?
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun add(mediaPlayCtrlWidgetEntity: MediaPlayerControlsWidgetEntity)
@Query("DELETE FROM mediaplayctrls_widgets WHERE id = :id")
@Query("DELETE FROM media_player_controls_widgets WHERE id = :id")
override suspend fun delete(id: Int)
@Query("DELETE FROM mediaplayctrls_widgets WHERE id IN (:ids)")
@Query("DELETE FROM media_player_controls_widgets WHERE id IN (:ids)")
suspend fun deleteAll(ids: IntArray)
@Query("SELECT * FROM mediaplayctrls_widgets")
@Query("SELECT * FROM media_player_controls_widgets")
suspend fun getAll(): List<MediaPlayerControlsWidgetEntity>
@Query("SELECT * FROM mediaplayctrls_widgets")
@Query("SELECT * FROM media_player_controls_widgets")
fun getAllFlow(): Flow<List<MediaPlayerControlsWidgetEntity>>
}

View file

@ -4,21 +4,21 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "mediaplayctrls_widgets")
@Entity(tableName = "media_player_controls_widgets")
data class MediaPlayerControlsWidgetEntity(
@PrimaryKey
override val id: Int,
@ColumnInfo(name = "entityId")
@ColumnInfo(name = "entity_id")
val entityId: String,
@ColumnInfo(name = "label")
val label: String?,
@ColumnInfo(name = "showSkip")
@ColumnInfo(name = "show_skip")
val showSkip: Boolean,
@ColumnInfo(name = "showSeek")
@ColumnInfo(name = "show_seek")
val showSeek: Boolean,
@ColumnInfo(name = "showVolume")
@ColumnInfo(name = "show_volume")
val showVolume: Boolean,
@ColumnInfo(name = "showSource", defaultValue = "false")
@ColumnInfo(name = "show_source", defaultValue = "false")
val showSource: Boolean,
@ColumnInfo(name = "background_type", defaultValue = "DAYNIGHT")
override val backgroundType: WidgetBackgroundType = WidgetBackgroundType.DAYNIGHT,