feat: add recipe management support

- Add `LocalRecipeEntity` and database migration 3->4
- Update `LocalCustomFoodEntity` with category support
- Include DAO methods for recipe persistence
This commit is contained in:
bleackstorm committed 2026-11-20 21:10:19 +01:00
1 parent 097d4b521e
commit d4d5d77d71
41 files changed
+5264 -1901

No files matched your search

@@ -12,8 +12,8 @@ import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
@Database(
entities = [LocalMealEntity::class, LocalCustomFoodEntity::class],
version = 3,
entities = [LocalMealEntity::class, LocalCustomFoodEntity::class, LocalRecipeEntity::class],
version = 4,
exportSchema = false
)
@TypeConverters(RoomConverters::class)
@@ -93,6 +93,30 @@ abstract class AppDatabase : RoomDatabase() {
}
}
val MIGRATION_3_4 = object : Migration(3, 4) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL(
"ALTER TABLE `local_custom_foods` ADD COLUMN `category` TEXT NOT NULL DEFAULT ''"
)
db.execSQL(
"""
CREATE TABLE IF NOT EXISTS `local_recipes` (
`id` TEXT NOT NULL PRIMARY KEY,
`title` TEXT NOT NULL,
`categoryTag` TEXT NOT NULL,
`prepTimeMinutes` INTEGER NOT NULL,
`servings` INTEGER NOT NULL,
`ingredients` TEXT NOT NULL,
`steps` TEXT NOT NULL,
`notes` TEXT NOT NULL,
`photoUri` TEXT,
`updatedAt` INTEGER NOT NULL
)
""".trimIndent()
)
}
}
fun getInstance(context: Context): AppDatabase {
return INSTANCE ?: synchronized(this) {
INSTANCE ?: buildDatabase(context.applicationContext).also { INSTANCE = it }
@@ -104,7 +128,7 @@ abstract class AppDatabase : RoomDatabase() {
appContext,
AppDatabase::class.java,
"satiea_local.db"
).addMigrations(MIGRATION_1_2, MIGRATION_2_3)
).addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4)
// Destructive migration is only permitted on debug builds
if (BuildConfig.DEBUG) {