-- 005_catalog_expansion_and_ingredient_linking.sql
-- Expands nutrition catalog, links recipe ingredients, recalculates recipe macros.
-- Coverage estimate: ~1160/1360 ingredient rows linkable; spice-skip 58; unmapped names 26 (mostly spice mixes)
-- Apply after scripts 001-004.
BEGIN;

-- 1. Add missing catalog items
INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Milk 2%', 'Mleko 2%', 50, 3.4, 2.0, 4.8, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'dairy'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Feta cheese', 'Ser feta', 264, 14.0, 21.0, 4.0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'dairy'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Ricotta', 'Ricotta', 174, 11.0, 13.0, 3.0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'dairy'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Parmesan', 'Parmezan', 431, 38.0, 29.0, 4.1, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'dairy'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Sour cream 12%', 'Śmietana 12%', 130, 2.7, 12.0, 3.0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'dairy'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Rye bread whole grain', 'Chleb żytni razowy', 217, 8.5, 1.8, 42.0, 5.5, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Pasta whole grain dry', 'Makaron pełnoziarnisty (suchy)', 348, 12.0, 2.0, 72.0, 3.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'White rice dry', 'Ryż biały (suchy)', 360, 7.0, 0.6, 79.0, 1.3, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Brown rice dry', 'Ryż brązowy (suchy)', 362, 7.5, 2.7, 76.0, 3.4, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Buckwheat groats dry', 'Kasza gryczana (sucha)', 343, 13.0, 3.4, 72.0, 10.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Bulgur dry', 'Kasza bulgur (sucha)', 342, 12.0, 1.3, 76.0, 12.5, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Couscous dry', 'Kuskus (suchy)', 376, 13.0, 0.6, 77.0, 5.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Whole wheat tortilla', 'Tortilla pełnoziarnista', 298, 9.0, 7.0, 48.0, 6.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Wheat flour type 1850', 'Mąka pszenna typ 1850', 340, 10.0, 1.0, 72.0, 2.7, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Breadcrumbs whole grain', 'Bułka tarta pełnoziarnista', 395, 13.0, 5.0, 72.0, 4.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Green beans', 'Fasolka szparagowa', 31, 1.8, 0.2, 7.0, 2.7, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Eggplant', 'Bakłażan', 25, 1.0, 0.2, 6.0, 3.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Radish', 'Rzodkiewka', 16, 0.7, 0.1, 3.4, 1.6, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Lettuce mix', 'Sałata / mix sałat', 15, 1.4, 0.2, 2.9, 1.3, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Leek', 'Por', 61, 1.5, 0.3, 14.0, 1.8, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Celery root', 'Seler korzeniowy', 42, 1.5, 0.3, 9.0, 1.8, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Celery stalk', 'Seler naciowy', 16, 0.7, 0.2, 3.0, 1.6, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Cauliflower', 'Kalafior', 25, 1.9, 0.3, 5.0, 2.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Parsley fresh', 'Pietruszka / natka', 36, 3.0, 0.8, 6.3, 3.3, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Chives', 'Szczypiorek', 30, 3.3, 0.7, 4.4, 2.5, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Dill fresh', 'Koper ogrodowy', 43, 3.5, 1.1, 7.0, 2.1, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Capers', 'Kapary', 23, 2.4, 0.9, 4.9, 3.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Olives black', 'Oliwki czarne', 115, 0.8, 10.7, 6.0, 3.2, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Olives green', 'Oliwki zielone', 145, 1.0, 15.0, 3.8, 3.3, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Garlic', 'Czosnek', 149, 6.4, 0.5, 33.0, 2.1, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Sweet corn canned', 'Kukurydza konserwowa', 86, 2.5, 1.0, 19.0, 2.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Raspberries', 'Maliny', 52, 1.2, 0.7, 12.0, 6.5, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Kiwi', 'Kiwi', 61, 1.1, 0.5, 15.0, 3.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Mango', 'Mango', 60, 0.8, 0.4, 15.0, 1.6, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Peach nectarine', 'Brzoskwinia / nektarynka', 44, 0.9, 0.3, 11.0, 1.5, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Lemon juice', 'Sok cytrynowy / cytryna', 22, 0.4, 0.2, 6.9, 0.3, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Pomegranate seeds', 'Pestki granatu', 83, 1.7, 1.2, 19.0, 4.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Dried apricots', 'Suszone morele', 241, 3.4, 0.5, 63.0, 7.3, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Dried figs', 'Suszone figi', 249, 3.3, 0.9, 63.9, 9.8, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Dried cranberries', 'Żurawina suszona', 308, 0.1, 1.4, 82.0, 5.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Honey', 'Miód', 304, 0.3, 0.0, 82.0, 0.2, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'nuts'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Tahini', 'Tahini', 595, 17.0, 54.0, 21.0, 9.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'nuts'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Hummus', 'Hummus', 166, 8.0, 9.6, 14.0, 6.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'legumes'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Pesto basil', 'Pesto bazyliowe', 420, 5.0, 40.0, 6.0, 2.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'oils'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Tomato passata', 'Passata / pomidory z puszki', 32, 1.5, 0.2, 5.0, 1.5, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Sun-dried tomatoes in oil', 'Suszone pomidory w oliwie', 258, 14.0, 3.0, 55.0, 12.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Jam strawberry low sugar', 'Dżem truskawkowy niskosłodzony', 180, 0.5, 0.1, 45.0, 1.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Ketchup', 'Keczup', 100, 1.0, 0.2, 25.0, 0.5, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Mustard dijon', 'Musztarda dijonska', 66, 4.0, 3.7, 5.0, 3.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Soy sauce', 'Sos sojowy', 53, 8.0, 0.0, 4.9, 0.8, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Carrot juice', 'Sok marchwiowy', 40, 0.9, 0.2, 9.6, 0.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fruits'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Flaxseed oil', 'Olej lniany', 884, 0.0, 100.0, 0.0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'oils'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Flax seeds ground', 'Siemię lniane', 534, 18.0, 42.0, 29.0, 27.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'nuts'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Pumpkin seeds', 'Pestki dyni', 559, 30.0, 49.0, 11.0, 6.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'nuts'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Pistachios', 'Pistacje', 562, 20.0, 45.0, 28.0, 10.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'nuts'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Pine nuts', 'Piniole', 673, 14.0, 68.0, 13.0, 3.7, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'nuts'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Coconut flakes', 'Wiórki kokosowe', 660, 7.0, 65.0, 24.0, 16.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'nuts'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Smoked salmon', 'Łosoś wędzony', 117, 18.0, 4.3, 0.0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'fish'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Chicken liver', 'Wątróbka kurczaka', 167, 26.0, 6.5, 1.0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'poultry'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Pork tenderloin', 'Polędwica wieprzowa', 143, 26.0, 3.5, 0.0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'meat'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Beef stew meat', 'Wołowina gulaszowa', 250, 26.0, 15.0, 0.0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'meat'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Beef strips', 'Wołowina (rostbef)', 271, 25.8, 18.0, 0.0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'meat'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

-- Herbs, spices, and zero-calorie liquids (for remaining unmapped ingredient rows with grams)
INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Water', 'Woda', 0, 0, 0, 0, NULL, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Basil fresh', 'Bazylia świeża', 23, 3.2, 0.6, 2.7, 1.6, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Basil dried', 'Bazylia suszona', 251, 14.4, 4.1, 47.8, 37.7, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Oregano dried', 'Oregano suszone', 265, 9.0, 4.3, 68.9, 42.5, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Thyme dried', 'Tymianek suszony', 276, 9.1, 7.4, 63.9, 37.0, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Rosemary dried', 'Rozmaryn suszony', 331, 4.9, 15.2, 64.1, 42.6, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Cinnamon ground', 'Cynamon mielony', 247, 4.0, 1.2, 80.6, 53.1, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Ginger ground', 'Imbir mielony', 335, 9.0, 4.2, 71.6, 14.1, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Coriander dried', 'Kolendra suszona', 298, 12.4, 17.8, 54.9, 41.9, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Marjoram dried', 'Majeranek suszony', 271, 12.7, 7.0, 60.6, 40.3, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Black pepper ground', 'Pieprz czarny mielony', 251, 10.4, 3.3, 63.9, 25.3, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'vegetables'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

INSERT INTO diet."IngredientNutritionCatalog"
    ("CategoryId", "Name", "NamePl", "CaloriesPer100G", "ProteinGPer100G", "FatGPer100G", "CarbsGPer100G", "FiberGPer100G", "SortOrder")
SELECT c."Id", 'Cocoa powder 16% fat', 'Kakao 16% proszek', 228, 19.6, 13.7, 57.9, 33.2, 100
FROM diet."IngredientCategories" c WHERE c."Code" = 'grains'
ON CONFLICT ("CategoryId", "Name") DO UPDATE SET
    "NamePl" = EXCLUDED."NamePl", "CaloriesPer100G" = EXCLUDED."CaloriesPer100G",
    "ProteinGPer100G" = EXCLUDED."ProteinGPer100G", "FatGPer100G" = EXCLUDED."FatGPer100G",
    "CarbsGPer100G" = EXCLUDED."CarbsGPer100G", "FiberGPer100G" = EXCLUDED."FiberGPer100G", "IsActive" = true;

CREATE TEMP TABLE _ingredient_name_map (pattern text PRIMARY KEY, catalog_name text NOT NULL);
INSERT INTO _ingredient_name_map VALUES ('Awokado', 'Avocado') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Bakłażan', 'Eggplant') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Bazylia suszona', 'Basil dried') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Bazylia świeża', 'Basil fresh') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Banan', 'Banana') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Bataty', 'Potato') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Borówki amerykańskie', 'Blueberries') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Brokuł', 'Broccoli') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Brokuły', 'Broccoli') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Brzoskwinia', 'Peach nectarine') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Brzoskwinia (świeża lub mrożona)', 'Peach nectarine') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Bułka tarta pełnoziarnista', 'Breadcrumbs whole grain') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Cebula', 'Onion') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Cebula czerwona', 'Onion') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Chleb pita pełnoziarnisty', 'Whole wheat bread') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Chleb żytni razowy', 'Rye bread whole grain') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ciecierzyca z puszki', 'Chickpeas (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ciecierzyca z puszki (odsączona)', 'Chickpeas (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Cukinia', 'Zucchini') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Cynamon', 'Cinnamon ground') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Cytryna', 'Lemon juice') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Cytryna (sok)', 'Lemon juice') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Czosnek', 'Garlic') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Czosnek granulowany', 'Garlic') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Czosnek, sól, pieprz', 'Garlic') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Czosnek, sół, pieprz', 'Garlic') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Czosnek, tymianek, sól, pieprz', 'Garlic') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Dorsz świeży filety bez skóry', 'Cod') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Dynia pestki łuskane', 'Pumpkin seeds') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Dżem truskawkowy niskosłodzony', 'Strawberries') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Fasola czerwona w zalewie (konserwowa)', 'Kidney beans (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Fasola szparagowa', 'Green beans') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Fasolka szparagowa', 'Green beans') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Fasolka szparagowa mrożona', 'Green beans') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Filet z dorsza lub dorada', 'Cod') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Filet z piersi indyka', 'Turkey breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Filet z piersi indyka (rozbite plastry)', 'Turkey breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Filet z łososia', 'Salmon') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Gruszka', 'Peach nectarine') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Hummus', 'Hummus') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Imbir mielony', 'Ginger ground') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Jabłko', 'Apple') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Jaja kurze całe', 'Chicken egg (whole)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Jaja kurze całe (na twardo)', 'Chicken egg (whole)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Jajko', 'Chicken egg (whole)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Jajko (do klopsików)', 'Chicken egg (whole)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Jajko (do panierki)', 'Chicken egg (whole)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Jajko ugotowane na twardo', 'Chicken egg (whole)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Jogurt grecki 2%', 'Greek yogurt (plain)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Jogurt naturalny', 'Greek yogurt (plain)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kakao 16% proszek', 'Cocoa powder 16% fat') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kabanosy z kurczaka', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kalafior', 'Cauliflower') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kapary', 'Capers') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kasza bulgur', 'Bulgur dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kasza gryczana', 'Buckwheat groats dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kasza jaglana', 'Buckwheat groats dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Keczup', 'Ketchup') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kiełbasa chorizo', 'Ham (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kiełki brokuła', 'Broccoli') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kiwi', 'Kiwi') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Koncentrat pomidorowy 30%', 'Tomato passata') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kolendra suszone liście', 'Coriander dried') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Koper ogrodowy', 'Dill fresh') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kukurydza konserwowa', 'Sweet corn canned') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Kuskus pełnoziarnisty', 'Couscous dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Len mielony', 'Flax seeds ground') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Len nasiona', 'Flax seeds ground') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Len, nasiona', 'Flax seeds ground') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Makaron fusilli pełnoziarnisty', 'Pasta whole grain dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Makaron penne pełnoziarnisty', 'Pasta whole grain dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Makaron pełnoziarnisty', 'Pasta whole grain dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Makaron pełnoziarnisty (fusilli)', 'Pasta whole grain dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Makaron pełnoziarnisty (penne lub spaghetti)', 'Pasta whole grain dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Makaron pełnoziarnisty (tagliatelle lub penne)', 'Pasta whole grain dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Makaron rigatoni pełnoziarnisty', 'Pasta whole grain dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Makaron spaghetti pełnoziarnisty', 'Pasta whole grain dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Makaron tagliatelle pełnoziarnisty', 'Pasta whole grain dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Majeranek', 'Marjoram dried') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Maliny', 'Raspberries') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Maliny (świeże lub mrożone)', 'Raspberries') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Maliny świeże lub mrożone', 'Raspberries') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mango (świeże lub mrożone)', 'Mango') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Marchew', 'Carrot') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Marchewka', 'Carrot') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Masło', 'Butter') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Masło ekstra', 'Butter') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Masło orzechowe', 'Butter') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Migdały', 'Almonds') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Migdały w płatkach', 'Almonds') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mix sałat', 'Lettuce mix') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Miód', 'Honey') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Miód pszczeli', 'Honey') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mięso wołowe (świeżo mielone z rostbefu)', 'Ground beef (15% fat)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mięso wołowe mielone', 'Ground beef (15% fat)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mięso z piersi kurczaka bez skóry', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mięso z podudzia indyka bez skóry', 'Turkey breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mleko 2%', 'Milk 2%') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mleko spożywcze 2%', 'Milk 2%') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Morszczuk świeży', 'Cod') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Musztarda dijonska', 'Mustard dijon') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mąka pszenna (do obtoczenia)', 'Wheat flour type 1850') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Mąka pszenna typ 1850', 'Wheat flour type 1850') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Nasiona chia', 'Chia seeds') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Natka pietruszki', 'Parsley fresh') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Nektarynka', 'Peach nectarine') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Noga (udo) kurczaka', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ocet jabłkowy z dojrzałych jabłek', 'Apple') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Olej lniany tłoczony na zimno', 'Flaxseed oil') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Oliwa z oliwek', 'Olive oil') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Oliwki czarne', 'Olives black') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Oliwki czarne i zielone (mix)', 'Olives black') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Oliwki zielone', 'Olives green') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Oliwki zielone marynowane', 'Olives green') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Oregano suszone', 'Oregano dried') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Oregano, sok cytryny, sól, pieprz', 'Lemon juice') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Oregano, tymianek, czosnek granulowany, sól', 'Garlic') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Orzechy nerkowca', 'Cashews') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Orzechy nerkowca (bez soli)', 'Cashews') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Orzechy włoskie', 'Walnuts') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Papryka czerwona', 'Bell pepper') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Parmezan tarty', 'Parmesan') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Parmezan w płatkach', 'Parmesan') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Passata pomidorowa', 'Tomato passata') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Passata pomidorowa (przecier)', 'Tomato passata') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Passata pomidorowa przecier', 'Tomato passata') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pestki granatu', 'Pomegranate seeds') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pesto bazyliowe', 'Pesto basil') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pieczarka uprawna świeża', 'Mushrooms') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pieczarki świeże', 'Mushrooms') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pieprz czarny mielony', 'Black pepper ground') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pierś z indyka', 'Turkey breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pierś z kurczaka', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pierś z kurczaka (rozbita cienko)', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pierś z kurczaka (ugotowana lub z poprzedniego dnia)', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pierś z kurczaka (z poprzedniego dnia lub świeża)', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pietruszka korzeń', 'Celery root') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pietruszka liście', 'Parsley fresh') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pietruszka, liście', 'Parsley fresh') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Piniole', 'Pine nuts') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pistacje (łuskane)', 'Pistachios') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pistacje łuskane', 'Pistachios') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Polędwica sopocka', 'Ham (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Polędwica wieprzowa', 'Pork tenderloin') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Polędwica wieprzowa surowa', 'Pork tenderloin') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pomarańcza', 'Orange') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pomidor', 'Tomato') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pomidory cherry', 'Tomato') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pomidory koktajlowe', 'Tomato') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pomidory z puszki', 'Tomato passata') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Pomidory z puszki (krojone)', 'Tomato passata') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Por', 'Leek') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Płatki owsiane', 'Oats (dry)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ricotta', 'Ricotta') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Rozmaryn', 'Rosemary dried') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Rukola', 'Lettuce mix') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ryż basmati', 'White rice dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ryż brązowy', 'Brown rice dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ryż jaśminowy', 'White rice dry') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Rzodkiewka', 'Radish') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Salami', 'Ham (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Salami (cienkie plastry)', 'Ham (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Sałata', 'Lettuce mix') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Sałata lub mix sałat', 'Lettuce mix') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Seler korzeniowy', 'Celery root') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Seler naciowy', 'Celery stalk') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ser feta', 'Feta cheese') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ser gouda tłusty', 'Parmesan') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ser mozzarella', 'Mozzarella') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ser parmezan (tarty)', 'Parmesan') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ser parmezan tarty', 'Parmesan') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ser twarogowy półtłusty', 'Cottage cheese') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ser typu feta', 'Feta cheese') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Serek wiejski naturalny', 'Greek yogurt (plain)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Siemię lniane mielone', 'Flax seeds ground') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Siemię lniane świeżo mielone', 'Flax seeds ground') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Soczewica zielona', 'Lentils (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Soczewica zielona (ugotowana)', 'Lentils (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Sok cytrynowy', 'Lemon juice') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Sok marchwiowy', 'Carrot juice') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Sos sojowy', 'Soy sauce') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Sos sojowy ciemny', 'Soy sauce') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Suszone figi', 'Dried figs') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Suszone morele', 'Dried apricots') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Suszone pomidory (odsączone)', 'Sun-dried tomatoes in oil') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Suszone pomidory (w oleju z ziołami, odsączone)', 'Sun-dried tomatoes in oil') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Suszone pomidory w oliwie (odsączone)', 'Sun-dried tomatoes in oil') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Szczypiorek', 'Chives') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Szpinak', 'Spinach') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Szpinak świeży', 'Spinach') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Szynka parmeńska', 'Ham (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Szynka parmeńska (Prosciutto)', 'Ham (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Szynka parmeńska (prosciutto)', 'Ham (cooked)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Szynka z indyka', 'Turkey breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Szynka z indyka (bez konserwantów)', 'Turkey breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Słonecznik nasiona łuskane', 'Pumpkin seeds') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Tahini', 'Tahini') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Tortilla pełnoziarnista', 'Whole wheat tortilla') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Truskawki', 'Strawberries') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Truskawki (świeże lub mrożone)', 'Strawberries') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Tuńczyk w wodzie (odsączony)', 'Tuna (canned in water)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Twaróg półtłusty', 'Cottage cheese') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Tymianek', 'Thyme dried') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Tymianek, czosnek granulowany, sól', 'Garlic') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Tymianek, czosnek granulowany, sól, pieprz', 'Garlic') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Udka kurczaka (bez skóry)', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Udka kurczaka bez skóry', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Wiórki kokosowe', 'Coconut flakes') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Woda', 'Water') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Wołowina (rostbef lub ligawa, cienkie paski)', 'Beef stew meat') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Wołowina gulaszowa', 'Beef stew meat') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Wołowina gulaszowa (karkówka/łopatka)', 'Beef stew meat') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Wołowina mielona', 'Ground beef (15% fat)') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Wątróbka kurczaka', 'Chicken breast') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Ziemniaki', 'Potato') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Łosoś wędzony', 'Smoked salmon') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Śmietana 12%', 'Sour cream 12%') ON CONFLICT DO NOTHING;
INSERT INTO _ingredient_name_map VALUES ('Żurawina suszona', 'Dried cranberries') ON CONFLICT DO NOTHING;

UPDATE diet."Ingredients" i
SET "CatalogItemId" = c."Id"
FROM _ingredient_name_map m
JOIN diet."IngredientNutritionCatalog" c ON c."Name" = m.catalog_name AND c."IsActive" = true
WHERE i."Name" = m.pattern AND i."AmountGrams" IS NOT NULL AND i."AmountGrams" > 0;

WITH totals AS (
    SELECT i."RecipeId",
        ROUND(SUM(c."CaloriesPer100G" * i."AmountGrams" / 100.0))::int AS calories,
        ROUND(SUM(c."ProteinGPer100G" * i."AmountGrams" / 100.0), 2) AS protein,
        ROUND(SUM(c."FatGPer100G" * i."AmountGrams" / 100.0), 2) AS fat,
        ROUND(SUM(c."CarbsGPer100G" * i."AmountGrams" / 100.0), 2) AS carbs
    FROM diet."Ingredients" i
    JOIN diet."IngredientNutritionCatalog" c ON c."Id" = i."CatalogItemId"
    WHERE i."AmountGrams" IS NOT NULL AND i."AmountGrams" > 0
    GROUP BY i."RecipeId"
)
UPDATE diet."Recipes" r SET
    "Calories" = t.calories, "Protein" = t.protein, "Fat" = t.fat, "Carbs" = t.carbs, "UpdatedAt" = now()
FROM totals t WHERE r."Id" = t."RecipeId" AND r."IsActive" = true;

DO $$
DECLARE unlinked int; no_macros int;
BEGIN
    SELECT COUNT(*) INTO unlinked FROM diet."Ingredients"
    WHERE "AmountGrams" > 0 AND "CatalogItemId" IS NULL AND COALESCE("Unit", '') <> 'do smaku';
    SELECT COUNT(*) INTO no_macros FROM diet."Recipes" WHERE "IsActive" AND ("Protein" IS NULL OR "Calories" IS NULL);
    RAISE NOTICE 'Unlinked ingredient rows (grams, non-spice): %', unlinked;
    RAISE NOTICE 'Recipes still missing macros: %', no_macros;
END $$;

COMMIT;

-- Reference mapping: database/scripts/005_ingredient_name_mapping.csv
