package com.develop.food.base.repo.db

import androidx.room.Database
import androidx.room.RoomDatabase
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import com.develop.food.base.repo.db.dao.FoodConfigDao
import com.develop.food.base.repo.db.dao.FoodRecipeDao
import com.develop.food.base.repo.entity.*
import com.develop.food.base.utils.StringUtils

// 版本2到版本3的迁移策略
val FOOD_MIGRATION_2_3: Migration = object : Migration(2, 3) {
    override fun migrate(database: SupportSQLiteDatabase) {
        database.execSQL("ALTER TABLE cc_dev_recipe ADD COLUMN food_description TEXT")
        database.execSQL("ALTER TABLE cc_dev_recipe ADD COLUMN chef_rec TEXT")
    }
}


@Database(entities = [
    DevAccessory::class,
    DevHotTag::class,
    DevPortrait::class,
    DevRecipe::class,
    DevRecipeAccessory::class,
    DevRecipeCategory::class,
    DevRecipeCookingStep::class,
    DevRecipeFood::class,
    DevRecipeNutrition::class,
    DevRecipePortionSize::class,
    DevRecipeRelTag::class,
    DevRecipeTag::class
], version = StringUtils.roomVersion, exportSchema = false)
abstract class FoodDatabase: RoomDatabase() {

    abstract fun recipeDao(): FoodRecipeDao

    abstract fun configDao(): FoodConfigDao

}