Files
food-ai/backend/migrations/002_seed_data.sql
dbastrikin 61feb91bba feat: core schema redesign — dishes, structured recipes, cuisines, tags (iteration 7)
Replaces the flat JSONB-based recipe schema with a normalized relational model:

Schema (migrations consolidated to 001_initial_schema + 002_seed_data):
- New: dishes, dish_translations, dish_tags — canonical dish catalog
- New: cuisines, tags, dish_categories with _translations tables + full seed data
- New: recipe_ingredients, recipe_steps with _translations (replaces JSONB blobs)
- New: user_saved_recipes thin bookmark (drops saved_recipes + saved_recipe_translations)
- New: product_ingredients M2M table
- recipes: now a cooking variant of a dish (dish_id FK, no title/JSONB columns)
- recipe_translations: repurposed to per-language notes only
- products: mapping_id → primary_ingredient_id
- menu_items: recipe_id FK → recipes; adds dish_id
- meal_diary: adds dish_id, recipe_id → recipes, portion_g

Backend (Go):
- New packages: internal/cuisine, internal/tag, internal/dish (registry + handler + repo)
- New GET /cuisines, GET /tags (public), GET /dishes, GET /dishes/{id}, GET /recipes/{id}
- recipe, savedrecipe, menu, diary, product, ingredient packages updated for new schema

Flutter:
- New models: Cuisine, Tag; new providers: cuisineNamesProvider, tagNamesProvider
- recipe.dart: RecipeIngredient gains unit_code + effectiveUnit getter
- saved_recipe.dart: thin model, manual fromJson, computed nutrition getter
- diary_entry.dart: adds dishId, recipeId, portionG
- recipe_detail_screen.dart: localized cuisine/tag names via providers

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-15 18:01:24 +02:00

191 lines
8.0 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- +goose Up
-- ---------------------------------------------------------------------------
-- languages
-- ---------------------------------------------------------------------------
INSERT INTO languages (code, native_name, english_name, sort_order) VALUES
('en', 'English', 'English', 1),
('ru', 'Русский', 'Russian', 2),
('es', 'Español', 'Spanish', 3),
('de', 'Deutsch', 'German', 4),
('fr', 'Français', 'French', 5),
('it', 'Italiano', 'Italian', 6),
('pt', 'Português', 'Portuguese', 7),
('zh', '中文', 'Chinese (Simplified)', 8),
('ja', '日本語', 'Japanese', 9),
('ko', '한국어', 'Korean', 10),
('ar', 'العربية', 'Arabic', 11),
('hi', 'हिन्दी', 'Hindi', 12);
-- ---------------------------------------------------------------------------
-- units + unit_translations
-- ---------------------------------------------------------------------------
INSERT INTO units (code, sort_order) VALUES
('g', 1),
('kg', 2),
('ml', 3),
('l', 4),
('pcs', 5),
('pack', 6);
INSERT INTO unit_translations (unit_code, lang, name) VALUES
('g', 'ru', 'г'),
('kg', 'ru', 'кг'),
('ml', 'ru', 'мл'),
('l', 'ru', 'л'),
('pcs', 'ru', 'шт'),
('pack', 'ru', 'уп');
-- ---------------------------------------------------------------------------
-- ingredient_categories + ingredient_category_translations
-- ---------------------------------------------------------------------------
INSERT INTO ingredient_categories (slug, sort_order) VALUES
('dairy', 1),
('meat', 2),
('produce', 3),
('bakery', 4),
('frozen', 5),
('beverages', 6),
('other', 7);
INSERT INTO ingredient_category_translations (category_slug, lang, name) VALUES
('dairy', 'ru', 'Молочные продукты'),
('meat', 'ru', 'Мясо и птица'),
('produce', 'ru', 'Овощи и фрукты'),
('bakery', 'ru', 'Выпечка и хлеб'),
('frozen', 'ru', 'Замороженные'),
('beverages', 'ru', 'Напитки'),
('other', 'ru', 'Прочее');
-- ---------------------------------------------------------------------------
-- cuisines + cuisine_translations
-- ---------------------------------------------------------------------------
INSERT INTO cuisines (slug, name, sort_order) VALUES
('italian', 'Italian', 1),
('french', 'French', 2),
('russian', 'Russian', 3),
('chinese', 'Chinese', 4),
('japanese', 'Japanese', 5),
('korean', 'Korean', 6),
('mexican', 'Mexican', 7),
('mediterranean', 'Mediterranean', 8),
('indian', 'Indian', 9),
('thai', 'Thai', 10),
('american', 'American', 11),
('georgian', 'Georgian', 12),
('spanish', 'Spanish', 13),
('german', 'German', 14),
('middle_eastern', 'Middle Eastern', 15),
('turkish', 'Turkish', 16),
('greek', 'Greek', 17),
('vietnamese', 'Vietnamese', 18),
('other', 'Other', 19);
INSERT INTO cuisine_translations (cuisine_slug, lang, name) VALUES
('italian', 'ru', 'Итальянская'),
('french', 'ru', 'Французская'),
('russian', 'ru', 'Русская'),
('chinese', 'ru', 'Китайская'),
('japanese', 'ru', 'Японская'),
('korean', 'ru', 'Корейская'),
('mexican', 'ru', 'Мексиканская'),
('mediterranean', 'ru', 'Средиземноморская'),
('indian', 'ru', 'Индийская'),
('thai', 'ru', 'Тайская'),
('american', 'ru', 'Американская'),
('georgian', 'ru', 'Грузинская'),
('spanish', 'ru', 'Испанская'),
('german', 'ru', 'Немецкая'),
('middle_eastern', 'ru', 'Ближневосточная'),
('turkish', 'ru', 'Турецкая'),
('greek', 'ru', 'Греческая'),
('vietnamese', 'ru', 'Вьетнамская'),
('other', 'ru', 'Другая');
-- ---------------------------------------------------------------------------
-- tags + tag_translations
-- ---------------------------------------------------------------------------
INSERT INTO tags (slug, name, sort_order) VALUES
('vegan', 'Vegan', 1),
('vegetarian', 'Vegetarian', 2),
('gluten_free', 'Gluten-Free', 3),
('dairy_free', 'Dairy-Free', 4),
('healthy', 'Healthy', 5),
('quick', 'Quick', 6),
('spicy', 'Spicy', 7),
('sweet', 'Sweet', 8),
('soup', 'Soup', 9),
('salad', 'Salad', 10),
('main_course', 'Main Course', 11),
('appetizer', 'Appetizer', 12),
('breakfast', 'Breakfast', 13),
('dessert', 'Dessert', 14),
('grilled', 'Grilled', 15),
('baked', 'Baked', 16),
('fried', 'Fried', 17),
('raw', 'Raw', 18),
('fermented', 'Fermented', 19);
INSERT INTO tag_translations (tag_slug, lang, name) VALUES
('vegan', 'ru', 'Веганское'),
('vegetarian', 'ru', 'Вегетарианское'),
('gluten_free', 'ru', 'Без глютена'),
('dairy_free', 'ru', 'Без молока'),
('healthy', 'ru', 'Здоровое'),
('quick', 'ru', 'Быстрое'),
('spicy', 'ru', 'Острое'),
('sweet', 'ru', 'Сладкое'),
('soup', 'ru', 'Суп'),
('salad', 'ru', 'Салат'),
('main_course', 'ru', 'Основное блюдо'),
('appetizer', 'ru', 'Закуска'),
('breakfast', 'ru', 'Завтрак'),
('dessert', 'ru', 'Десерт'),
('grilled', 'ru', 'Жареное на гриле'),
('baked', 'ru', 'Запечённое'),
('fried', 'ru', 'Жареное'),
('raw', 'ru', 'Сырое'),
('fermented', 'ru', 'Ферментированное');
-- ---------------------------------------------------------------------------
-- dish_categories + dish_category_translations
-- ---------------------------------------------------------------------------
INSERT INTO dish_categories (slug, name, sort_order) VALUES
('soup', 'Soup', 1),
('salad', 'Salad', 2),
('main_course', 'Main Course', 3),
('side_dish', 'Side Dish', 4),
('appetizer', 'Appetizer', 5),
('dessert', 'Dessert', 6),
('breakfast', 'Breakfast', 7),
('drink', 'Drink', 8),
('bread', 'Bread', 9),
('sauce', 'Sauce', 10),
('snack', 'Snack', 11);
INSERT INTO dish_category_translations (category_slug, lang, name) VALUES
('soup', 'ru', 'Суп'),
('salad', 'ru', 'Салат'),
('main_course', 'ru', 'Основное блюдо'),
('side_dish', 'ru', 'Гарнир'),
('appetizer', 'ru', 'Закуска'),
('dessert', 'ru', 'Десерт'),
('breakfast', 'ru', 'Завтрак'),
('drink', 'ru', 'Напиток'),
('bread', 'ru', 'Выпечка'),
('sauce', 'ru', 'Соус'),
('snack', 'ru', 'Снэк');
-- +goose Down
DELETE FROM dish_category_translations;
DELETE FROM dish_categories;
DELETE FROM tag_translations;
DELETE FROM tags;
DELETE FROM cuisine_translations;
DELETE FROM cuisines;
DELETE FROM ingredient_category_translations;
DELETE FROM ingredient_categories;
DELETE FROM unit_translations;
DELETE FROM units;
DELETE FROM languages;