From 45b1b073729baf6a6f640d03f19538a6b4cc3143 Mon Sep 17 00:00:00 2001 From: Kirill Kamakin Date: Sat, 29 Oct 2022 17:33:39 +0200 Subject: [PATCH] Fix absent images on v0.5.6 --- .../data/network/MealieDataSourceWrapper.kt | 35 +- .../mealient/data/recipes/db/RecipeStorage.kt | 6 +- .../data/recipes/db/RecipeStorageImpl.kt | 6 +- .../data/recipes/network/RecipeDataSource.kt | 3 +- .../data/recipes/network/RecipeSummaryInfo.kt | 18 + .../extensions/RemoteToLocalMappings.kt | 32 +- .../ui/recipes/images/RecipeModelLoader.kt | 2 +- .../4.json | 410 ++++++++++++++++++ .../gq/kirmanak/mealient/database/AppDb.kt | 3 +- .../recipe/entity/RecipeSummaryEntity.kt | 3 +- 10 files changed, 483 insertions(+), 35 deletions(-) create mode 100644 app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeSummaryInfo.kt create mode 100644 database/schemas/gq.kirmanak.mealient.database.AppDb/4.json diff --git a/app/src/main/java/gq/kirmanak/mealient/data/network/MealieDataSourceWrapper.kt b/app/src/main/java/gq/kirmanak/mealient/data/network/MealieDataSourceWrapper.kt index fdf640f..c9205cc 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/network/MealieDataSourceWrapper.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/network/MealieDataSourceWrapper.kt @@ -6,13 +6,14 @@ import gq.kirmanak.mealient.data.baseurl.BaseURLStorage import gq.kirmanak.mealient.data.baseurl.VersionDataSource import gq.kirmanak.mealient.data.baseurl.VersionInfo import gq.kirmanak.mealient.data.recipes.network.RecipeDataSource +import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo import gq.kirmanak.mealient.datasource.MealieDataSource import gq.kirmanak.mealient.datasource.models.AddRecipeRequest import gq.kirmanak.mealient.datasource.models.GetRecipeResponse import gq.kirmanak.mealient.datasource.models.NetworkError import gq.kirmanak.mealient.datasource.v1.MealieDataSourceV1 -import gq.kirmanak.mealient.datasource.v1.models.GetRecipeSummaryResponseV1 import gq.kirmanak.mealient.extensions.runCatchingExceptCancel +import gq.kirmanak.mealient.extensions.toRecipeSummaryInfo import gq.kirmanak.mealient.extensions.toVersionInfo import javax.inject.Inject import javax.inject.Singleton @@ -21,48 +22,36 @@ import javax.inject.Singleton class MealieDataSourceWrapper @Inject constructor( private val baseURLStorage: BaseURLStorage, private val authRepo: AuthRepo, - private val mealieDataSource: MealieDataSource, - private val mealieDataSourceV1: MealieDataSourceV1, + private val source: MealieDataSource, + private val v1Source: MealieDataSourceV1, ) : AddRecipeDataSource, RecipeDataSource, VersionDataSource { override suspend fun addRecipe(recipe: AddRecipeRequest): String = - withAuthHeader { token -> mealieDataSource.addRecipe(getUrl(), token, recipe) } + withAuthHeader { token -> source.addRecipe(getUrl(), token, recipe) } override suspend fun getVersionInfo(baseUrl: String): VersionInfo = runCatchingExceptCancel { - mealieDataSource.getVersionInfo(baseUrl).toVersionInfo() + source.getVersionInfo(baseUrl).toVersionInfo() }.getOrElse { if (it is NetworkError.NotMealie) { - mealieDataSourceV1.getVersionInfo(baseUrl).toVersionInfo() + v1Source.getVersionInfo(baseUrl).toVersionInfo() } else { throw it } } - override suspend fun requestRecipes(start: Int, limit: Int): List = + override suspend fun requestRecipes(start: Int, limit: Int): List = withAuthHeader { token -> + val url = getUrl() if (isV1()) { - mealieDataSourceV1.requestRecipes(getUrl(), token, start, limit) + v1Source.requestRecipes(url, token, start, limit).map { it.toRecipeSummaryInfo() } } else { - mealieDataSource.requestRecipes(getUrl(), token, start, limit).map { - GetRecipeSummaryResponseV1( - remoteId = it.remoteId.toString(), - name = it.name, - slug = it.slug, - image = it.image, - description = it.description, - recipeCategories = it.recipeCategories, - tags = it.tags, - rating = it.rating, - dateAdded = it.dateAdded, - dateUpdated = it.dateUpdated, - ) - } + source.requestRecipes(url, token, start, limit).map { it.toRecipeSummaryInfo() } } } override suspend fun requestRecipeInfo(slug: String): GetRecipeResponse = - withAuthHeader { token -> mealieDataSource.requestRecipeInfo(getUrl(), token, slug) } + withAuthHeader { token -> source.requestRecipeInfo(getUrl(), token, slug) } private suspend fun getUrl() = baseURLStorage.requireBaseURL() diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorage.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorage.kt index 3b0d367..2d70c3c 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorage.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorage.kt @@ -1,17 +1,17 @@ package gq.kirmanak.mealient.data.recipes.db import androidx.paging.PagingSource +import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo import gq.kirmanak.mealient.database.recipe.entity.FullRecipeInfo import gq.kirmanak.mealient.database.recipe.entity.RecipeSummaryEntity import gq.kirmanak.mealient.datasource.models.GetRecipeResponse -import gq.kirmanak.mealient.datasource.v1.models.GetRecipeSummaryResponseV1 interface RecipeStorage { - suspend fun saveRecipes(recipes: List) + suspend fun saveRecipes(recipes: List) fun queryRecipes(): PagingSource - suspend fun refreshAll(recipes: List) + suspend fun refreshAll(recipes: List) suspend fun clearAllLocalData() diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorageImpl.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorageImpl.kt index ef203d8..aa6cdcb 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorageImpl.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/db/RecipeStorageImpl.kt @@ -2,11 +2,11 @@ package gq.kirmanak.mealient.data.recipes.db import androidx.paging.PagingSource import androidx.room.withTransaction +import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo import gq.kirmanak.mealient.database.AppDb import gq.kirmanak.mealient.database.recipe.RecipeDao import gq.kirmanak.mealient.database.recipe.entity.* import gq.kirmanak.mealient.datasource.models.GetRecipeResponse -import gq.kirmanak.mealient.datasource.v1.models.GetRecipeSummaryResponseV1 import gq.kirmanak.mealient.extensions.recipeEntity import gq.kirmanak.mealient.extensions.toRecipeEntity import gq.kirmanak.mealient.extensions.toRecipeIngredientEntity @@ -23,7 +23,7 @@ class RecipeStorageImpl @Inject constructor( private val recipeDao: RecipeDao by lazy { db.recipeDao() } override suspend fun saveRecipes( - recipes: List + recipes: List ) = db.withTransaction { logger.v { "saveRecipes() called with $recipes" } @@ -96,7 +96,7 @@ class RecipeStorageImpl @Inject constructor( return recipeDao.queryRecipesByPages() } - override suspend fun refreshAll(recipes: List) { + override suspend fun refreshAll(recipes: List) { logger.v { "refreshAll() called with: recipes = $recipes" } db.withTransaction { recipeDao.removeAllRecipes() diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeDataSource.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeDataSource.kt index 02e56b9..18fef8c 100644 --- a/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeDataSource.kt +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeDataSource.kt @@ -1,10 +1,9 @@ package gq.kirmanak.mealient.data.recipes.network import gq.kirmanak.mealient.datasource.models.GetRecipeResponse -import gq.kirmanak.mealient.datasource.v1.models.GetRecipeSummaryResponseV1 interface RecipeDataSource { - suspend fun requestRecipes(start: Int, limit: Int): List + suspend fun requestRecipes(start: Int, limit: Int): List suspend fun requestRecipeInfo(slug: String): GetRecipeResponse } \ No newline at end of file diff --git a/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeSummaryInfo.kt b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeSummaryInfo.kt new file mode 100644 index 0000000..49a67ab --- /dev/null +++ b/app/src/main/java/gq/kirmanak/mealient/data/recipes/network/RecipeSummaryInfo.kt @@ -0,0 +1,18 @@ +package gq.kirmanak.mealient.data.recipes.network + +import kotlinx.datetime.LocalDate +import kotlinx.datetime.LocalDateTime + +data class RecipeSummaryInfo( + val remoteId: String, + val name: String, + val slug: String, + val image: String?, + val description: String = "", + val recipeCategories: List, + val tags: List, + val rating: Int?, + val dateAdded: LocalDate, + val dateUpdated: LocalDateTime, + val imageId: String, +) diff --git a/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt b/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt index e2ec913..223402d 100644 --- a/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt +++ b/app/src/main/java/gq/kirmanak/mealient/extensions/RemoteToLocalMappings.kt @@ -1,6 +1,7 @@ package gq.kirmanak.mealient.extensions import gq.kirmanak.mealient.data.baseurl.VersionInfo +import gq.kirmanak.mealient.data.recipes.network.RecipeSummaryInfo import gq.kirmanak.mealient.database.recipe.entity.RecipeEntity import gq.kirmanak.mealient.database.recipe.entity.RecipeIngredientEntity import gq.kirmanak.mealient.database.recipe.entity.RecipeInstructionEntity @@ -33,7 +34,35 @@ fun GetRecipeInstructionResponse.toRecipeInstructionEntity(remoteId: String) = text = text ) -fun GetRecipeSummaryResponseV1.recipeEntity() = RecipeSummaryEntity( +fun GetRecipeSummaryResponse.toRecipeSummaryInfo() = RecipeSummaryInfo( + remoteId = remoteId.toString(), + name = name, + slug = slug, + image = image, + description = description, + recipeCategories = recipeCategories, + tags = tags, + rating = rating, + dateAdded = dateAdded, + dateUpdated = dateUpdated, + imageId = slug, +) + +fun GetRecipeSummaryResponseV1.toRecipeSummaryInfo() = RecipeSummaryInfo( + remoteId = remoteId, + name = name, + slug = slug, + image = image, + description = description, + recipeCategories = recipeCategories, + tags = tags, + rating = rating, + dateAdded = dateAdded, + dateUpdated = dateUpdated, + imageId = remoteId, +) + +fun RecipeSummaryInfo.recipeEntity() = RecipeSummaryEntity( remoteId = remoteId, name = name, slug = slug, @@ -42,6 +71,7 @@ fun GetRecipeSummaryResponseV1.recipeEntity() = RecipeSummaryEntity( rating = rating, dateAdded = dateAdded, dateUpdated = dateUpdated, + imageId = imageId, ) fun VersionResponse.toVersionInfo() = VersionInfo(version) diff --git a/app/src/main/java/gq/kirmanak/mealient/ui/recipes/images/RecipeModelLoader.kt b/app/src/main/java/gq/kirmanak/mealient/ui/recipes/images/RecipeModelLoader.kt index edb9704..a1651b3 100644 --- a/app/src/main/java/gq/kirmanak/mealient/ui/recipes/images/RecipeModelLoader.kt +++ b/app/src/main/java/gq/kirmanak/mealient/ui/recipes/images/RecipeModelLoader.kt @@ -44,7 +44,7 @@ class RecipeModelLoader private constructor( options: Options? ): String? { logger.v { "getUrl() called with: model = $model, width = $width, height = $height, options = $options" } - return runBlocking { recipeImageUrlProvider.generateImageUrl(model?.remoteId) } + return runBlocking { recipeImageUrlProvider.generateImageUrl(model?.imageId) } } override fun getHeaders( diff --git a/database/schemas/gq.kirmanak.mealient.database.AppDb/4.json b/database/schemas/gq.kirmanak.mealient.database.AppDb/4.json new file mode 100644 index 0000000..6b273aa --- /dev/null +++ b/database/schemas/gq.kirmanak.mealient.database.AppDb/4.json @@ -0,0 +1,410 @@ +{ + "formatVersion": 1, + "database": { + "version": 4, + "identityHash": "13be83018f147e1f6e864790656da4a7", + "entities": [ + { + "tableName": "categories", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`local_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "localId", + "columnName": "local_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "local_id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_categories_name", + "unique": true, + "columnNames": [ + "name" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_categories_name` ON `${TABLE_NAME}` (`name`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "category_recipe", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`category_id` INTEGER NOT NULL, `recipe_id` TEXT NOT NULL, PRIMARY KEY(`category_id`, `recipe_id`), FOREIGN KEY(`category_id`) REFERENCES `categories`(`local_id`) ON UPDATE CASCADE ON DELETE CASCADE , FOREIGN KEY(`recipe_id`) REFERENCES `recipe_summaries`(`remote_id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "categoryId", + "columnName": "category_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recipeId", + "columnName": "recipe_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "category_id", + "recipe_id" + ], + "autoGenerate": false + }, + "indices": [ + { + "name": "index_category_recipe_category_id_recipe_id", + "unique": true, + "columnNames": [ + "category_id", + "recipe_id" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_category_recipe_category_id_recipe_id` ON `${TABLE_NAME}` (`category_id`, `recipe_id`)" + }, + { + "name": "index_category_recipe_recipe_id", + "unique": false, + "columnNames": [ + "recipe_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_category_recipe_recipe_id` ON `${TABLE_NAME}` (`recipe_id`)" + } + ], + "foreignKeys": [ + { + "table": "categories", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "category_id" + ], + "referencedColumns": [ + "local_id" + ] + }, + { + "table": "recipe_summaries", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "recipe_id" + ], + "referencedColumns": [ + "remote_id" + ] + } + ] + }, + { + "tableName": "tags", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`local_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `name` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "localId", + "columnName": "local_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "local_id" + ], + "autoGenerate": true + }, + "indices": [ + { + "name": "index_tags_name", + "unique": true, + "columnNames": [ + "name" + ], + "orders": [], + "createSql": "CREATE UNIQUE INDEX IF NOT EXISTS `index_tags_name` ON `${TABLE_NAME}` (`name`)" + } + ], + "foreignKeys": [] + }, + { + "tableName": "tag_recipe", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`tag_id` INTEGER NOT NULL, `recipe_id` TEXT NOT NULL, PRIMARY KEY(`tag_id`, `recipe_id`), FOREIGN KEY(`tag_id`) REFERENCES `tags`(`local_id`) ON UPDATE CASCADE ON DELETE CASCADE , FOREIGN KEY(`recipe_id`) REFERENCES `recipe_summaries`(`remote_id`) ON UPDATE CASCADE ON DELETE CASCADE )", + "fields": [ + { + "fieldPath": "tagId", + "columnName": "tag_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recipeId", + "columnName": "recipe_id", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "tag_id", + "recipe_id" + ], + "autoGenerate": false + }, + "indices": [ + { + "name": "index_tag_recipe_recipe_id", + "unique": false, + "columnNames": [ + "recipe_id" + ], + "orders": [], + "createSql": "CREATE INDEX IF NOT EXISTS `index_tag_recipe_recipe_id` ON `${TABLE_NAME}` (`recipe_id`)" + } + ], + "foreignKeys": [ + { + "table": "tags", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "tag_id" + ], + "referencedColumns": [ + "local_id" + ] + }, + { + "table": "recipe_summaries", + "onDelete": "CASCADE", + "onUpdate": "CASCADE", + "columns": [ + "recipe_id" + ], + "referencedColumns": [ + "remote_id" + ] + } + ] + }, + { + "tableName": "recipe_summaries", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`remote_id` TEXT NOT NULL, `name` TEXT NOT NULL, `slug` TEXT NOT NULL, `image` TEXT, `description` TEXT NOT NULL, `rating` INTEGER, `date_added` INTEGER NOT NULL, `date_updated` INTEGER NOT NULL, `image_id` TEXT, PRIMARY KEY(`remote_id`))", + "fields": [ + { + "fieldPath": "remoteId", + "columnName": "remote_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "name", + "columnName": "name", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "slug", + "columnName": "slug", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "image", + "columnName": "image", + "affinity": "TEXT", + "notNull": false + }, + { + "fieldPath": "description", + "columnName": "description", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "rating", + "columnName": "rating", + "affinity": "INTEGER", + "notNull": false + }, + { + "fieldPath": "dateAdded", + "columnName": "date_added", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "dateUpdated", + "columnName": "date_updated", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "imageId", + "columnName": "image_id", + "affinity": "TEXT", + "notNull": false + } + ], + "primaryKey": { + "columnNames": [ + "remote_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recipe", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`remote_id` TEXT NOT NULL, `recipe_yield` TEXT NOT NULL, PRIMARY KEY(`remote_id`))", + "fields": [ + { + "fieldPath": "remoteId", + "columnName": "remote_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "recipeYield", + "columnName": "recipe_yield", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "remote_id" + ], + "autoGenerate": false + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recipe_ingredient", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`local_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `recipe_id` TEXT NOT NULL, `title` TEXT NOT NULL, `note` TEXT NOT NULL, `unit` TEXT NOT NULL, `food` TEXT NOT NULL, `disable_amount` INTEGER NOT NULL, `quantity` REAL NOT NULL)", + "fields": [ + { + "fieldPath": "localId", + "columnName": "local_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recipeId", + "columnName": "recipe_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "note", + "columnName": "note", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "unit", + "columnName": "unit", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "food", + "columnName": "food", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "disableAmount", + "columnName": "disable_amount", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "quantity", + "columnName": "quantity", + "affinity": "REAL", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "local_id" + ], + "autoGenerate": true + }, + "indices": [], + "foreignKeys": [] + }, + { + "tableName": "recipe_instruction", + "createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`local_id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `recipe_id` TEXT NOT NULL, `title` TEXT NOT NULL, `text` TEXT NOT NULL)", + "fields": [ + { + "fieldPath": "localId", + "columnName": "local_id", + "affinity": "INTEGER", + "notNull": true + }, + { + "fieldPath": "recipeId", + "columnName": "recipe_id", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "title", + "columnName": "title", + "affinity": "TEXT", + "notNull": true + }, + { + "fieldPath": "text", + "columnName": "text", + "affinity": "TEXT", + "notNull": true + } + ], + "primaryKey": { + "columnNames": [ + "local_id" + ], + "autoGenerate": true + }, + "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, '13be83018f147e1f6e864790656da4a7')" + ] + } +} \ No newline at end of file diff --git a/database/src/main/kotlin/gq/kirmanak/mealient/database/AppDb.kt b/database/src/main/kotlin/gq/kirmanak/mealient/database/AppDb.kt index 8ab22a8..b71d9d6 100644 --- a/database/src/main/kotlin/gq/kirmanak/mealient/database/AppDb.kt +++ b/database/src/main/kotlin/gq/kirmanak/mealient/database/AppDb.kt @@ -8,7 +8,7 @@ import gq.kirmanak.mealient.database.recipe.RecipeDao import gq.kirmanak.mealient.database.recipe.entity.* @Database( - version = 3, + version = 4, entities = [ CategoryEntity::class, CategoryRecipeEntity::class, @@ -22,6 +22,7 @@ import gq.kirmanak.mealient.database.recipe.entity.* exportSchema = true, autoMigrations = [ AutoMigration(from = 1, to = 2), + AutoMigration(from = 3, to = 4), ] ) @TypeConverters(RoomTypeConverters::class) diff --git a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeSummaryEntity.kt b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeSummaryEntity.kt index 5f89fee..0bde53e 100644 --- a/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeSummaryEntity.kt +++ b/database/src/main/kotlin/gq/kirmanak/mealient/database/recipe/entity/RecipeSummaryEntity.kt @@ -15,7 +15,8 @@ data class RecipeSummaryEntity( @ColumnInfo(name = "description") val description: String, @ColumnInfo(name = "rating") val rating: Int?, @ColumnInfo(name = "date_added") val dateAdded: LocalDate, - @ColumnInfo(name = "date_updated") val dateUpdated: LocalDateTime + @ColumnInfo(name = "date_updated") val dateUpdated: LocalDateTime, + @ColumnInfo(name = "image_id") val imageId: String?, ) { override fun toString(): String { return "RecipeSummaryEntity(remoteId=$remoteId, name='$name')"