-- ============================================================
-- seed_all.sql — Komplett seed för kategorier + produkter
--
-- Seeden är ensam sanningskälla för kategorier.
-- Den rensar Category-tabellen och bygger upp allt från scratch.
-- Product.categoryId nollställs och sätts om av STEG 3.
--
-- Kör på servern:
--   DB_PASS=$(grep MARIADB_ROOT_PASSWORD .env | cut -d= -f2)
--   docker exec -i recipe-db mariadb -uroot -p"$DB_PASS" recipe_app < db/seeds/seed_all.sql
-- ============================================================


-- ============================================================
-- RESET: Rensa kategorier och koppla bort produkter
-- ============================================================
SET foreign_key_checks = 0;
TRUNCATE TABLE `Category`;
SET foreign_key_checks = 1;
UPDATE `Product` SET `categoryId` = NULL;


-- ============================================================
-- STEG 1: KATEGORIER (komplett träd — enda sanningskällan)
-- ============================================================

-- ── NIVÅ 1: Toppkategorier ───────────────────────────────────
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Bröd & Kakor',         NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Dryck',                NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Färdigmat',            NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Fryst',                NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Frukt & Grönt',        NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Glass, godis & snacks', NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Kött, chark & fågel',  NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Mejeri, ost & ägg',    NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Skafferi',             NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Fisk & Skaldjur',      NULL);
INSERT INTO `Category` (`name`, `parentId`) VALUES ('Vegetariskt',          NULL);

-- ── NIVÅ 2: under Bröd & Kakor ──────────────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Bröd',               id FROM `Category` WHERE name = 'Bröd & Kakor'         AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Fastfoodbröd',       id FROM `Category` WHERE name = 'Bröd & Kakor'         AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Kex & Kakor',        id FROM `Category` WHERE name = 'Bröd & Kakor'         AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Knäckebröd & Skorpor', id FROM `Category` WHERE name = 'Bröd & Kakor'       AND parentId IS NULL;

-- ── NIVÅ 2: under Dryck ─────────────────────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Öl & cider',           id FROM `Category` WHERE name = 'Dryck'              AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Läsk och Energidryck', id FROM `Category` WHERE name = 'Dryck'              AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Juice, fruktdryck & smoothie', id FROM `Category` WHERE name = 'Dryck'   AND parentId IS NULL;

-- ── NIVÅ 2: under Färdigmat ─────────────────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Såser, grytbaser & övriga smaksättare', id FROM `Category` WHERE name = 'Färdigmat' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Gratäng & Röror mm',   id FROM `Category` WHERE name = 'Färdigmat'          AND parentId IS NULL;

-- ── NIVÅ 2: under Fryst ─────────────────────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Bageri',              id FROM `Category` WHERE name = 'Fryst'               AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Grönsaker & kryddor', id FROM `Category` WHERE name = 'Fryst'               AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Frukt & Bär',         id FROM `Category` WHERE name = 'Fryst'               AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Potatis',             id FROM `Category` WHERE name = 'Fryst'               AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Färdigmat',           id FROM `Category` WHERE name = 'Fryst'               AND parentId IS NULL;

-- ── NIVÅ 2: under Frukt & Grönt ─────────────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Potatis & rotsaker',  id FROM `Category` WHERE name = 'Frukt & Grönt'       AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Kryddor & smaksättare', id FROM `Category` WHERE name = 'Frukt & Grönt'     AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Grönsaker',           id FROM `Category` WHERE name = 'Frukt & Grönt'       AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Frukt',               id FROM `Category` WHERE name = 'Frukt & Grönt'       AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Färska bär',          id FROM `Category` WHERE name = 'Frukt & Grönt'       AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Svamp',               id FROM `Category` WHERE name = 'Frukt & Grönt'       AND parentId IS NULL;

-- ── NIVÅ 2: under Glass, godis & snacks ─────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Chips, snacks & dip', id FROM `Category` WHERE name = 'Glass, godis & snacks' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Choklad',             id FROM `Category` WHERE name = 'Glass, godis & snacks' AND parentId IS NULL;

-- ── NIVÅ 2: under Kött, chark & fågel ───────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Pålägg',              id FROM `Category` WHERE name = 'Kött, chark & fågel' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Chark',               id FROM `Category` WHERE name = 'Kött, chark & fågel' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Korv',                id FROM `Category` WHERE name = 'Kött, chark & fågel' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Kött',                id FROM `Category` WHERE name = 'Kött, chark & fågel' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Fågel',               id FROM `Category` WHERE name = 'Kött, chark & fågel' AND parentId IS NULL;

-- ── NIVÅ 2: under Mejeri, ost & ägg ─────────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Ost',                  id FROM `Category` WHERE name = 'Mejeri, ost & ägg'  AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Allergi mejeri',       id FROM `Category` WHERE name = 'Mejeri, ost & ägg'  AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Mjölk',                id FROM `Category` WHERE name = 'Mejeri, ost & ägg'  AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Filmjölk & Yoghurt',   id FROM `Category` WHERE name = 'Mejeri, ost & ägg'  AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Matlagning',           id FROM `Category` WHERE name = 'Mejeri, ost & ägg'  AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Smör, margarin & jäst', id FROM `Category` WHERE name = 'Mejeri, ost & ägg' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Havre-, Soja-, Risdryck mm', id FROM `Category` WHERE name = 'Mejeri, ost & ägg' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Kvarg & Cottage cheese', id FROM `Category` WHERE name = 'Mejeri, ost & ägg' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Mellanmål & desserter', id FROM `Category` WHERE name = 'Mejeri, ost & ägg' AND parentId IS NULL;

-- ── NIVÅ 2: under Skafferi ──────────────────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Kryddor & smaksättare', id FROM `Category` WHERE name = 'Skafferi'          AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Pasta, ris & matgryn',  id FROM `Category` WHERE name = 'Skafferi'          AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Oliver & delikatesser', id FROM `Category` WHERE name = 'Skafferi'          AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Konserver & burkar',    id FROM `Category` WHERE name = 'Skafferi'          AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Asien',                 id FROM `Category` WHERE name = 'Skafferi'          AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Torkad frukt',          id FROM `Category` WHERE name = 'Skafferi'          AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Torra baljväxter',      id FROM `Category` WHERE name = 'Skafferi'          AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Flingor, gryner & musli', id FROM `Category` WHERE name = 'Skafferi'       AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Torr färdigmat',        id FROM `Category` WHERE name = 'Skafferi'          AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Bakning',               id FROM `Category` WHERE name = 'Skafferi'          AND parentId IS NULL;

-- ── NIVÅ 2: under Fisk & Skaldjur ────────────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Fisk',                 id FROM `Category` WHERE name = 'Fisk & Skaldjur'   AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Sill, Ansjovis & Sardiner', id FROM `Category` WHERE name = 'Fisk & Skaldjur' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Skaldjur & Havsdelikatesser', id FROM `Category` WHERE name = 'Fisk & Skaldjur' AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Lakeprodukter',       id FROM `Category` WHERE name = 'Fisk & Skaldjur'   AND parentId IS NULL;

-- ── NIVÅ 2: under Vegetariskt ──────────────────────────────────
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Fryst',                id FROM `Category` WHERE name = 'Vegetariskt'       AND parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`) SELECT 'Tofu',                 id FROM `Category` WHERE name = 'Vegetariskt'       AND parentId IS NULL;

-- ── NIVÅ 3: under Bröd & Kakor > Bröd ──────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Matbröd', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Bröd'
  WHERE c1.name = 'Bröd & Kakor' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Rostbröd', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Bröd'
  WHERE c1.name = 'Bröd & Kakor' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Bröd & Kakor > Fastfoodbröd ─────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Hamburgerbröd', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Fastfoodbröd'
  WHERE c1.name = 'Bröd & Kakor' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Bröd & Kakor > Kex & Kakor ───────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Matkex', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kex & Kakor'
  WHERE c1.name = 'Bröd & Kakor' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Söta kex & kakor', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kex & Kakor'
  WHERE c1.name = 'Bröd & Kakor' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Bröd & Kakor > Knäckebröd & Skorpor ──────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Knäckebröd', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Knäckebröd & Skorpor'
  WHERE c1.name = 'Bröd & Kakor' AND c1.parentId IS NULL;
-- ── NIVÅ 3: under Dryck > Juice, fruktdryck & smoothie ─────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Kyld juice & nektar', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Juice, fruktdryck & smoothie'
  WHERE c1.name = 'Dryck' AND c1.parentId IS NULL;
-- ── NIVÅ 3: under Färdigmat > Såser, grytbaser... ───────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Dressing & övriga smaksättare', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Såser, grytbaser & övriga smaksättare'
  WHERE c1.name = 'Färdigmat' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Kylda såser', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Såser, grytbaser & övriga smaksättare'
  WHERE c1.name = 'Färdigmat' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Färdigmat > Gratäng & Röror mm ────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Krämiga sallader', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Gratäng & Röror mm'
  WHERE c1.name = 'Färdigmat' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Fryst > Bageri ────────────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Bröd & fikabröd', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Bageri'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Fryst > Grönsaker & kryddor ───────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Kryddor', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker & kryddor'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Grönsaker', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker & kryddor'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Fryst > Färdigmat ─────────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Pizza, paj & piroger', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Färdigmat'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Frukt & Grönt > Potatis & rotsaker ────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Lök', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Potatis & rotsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Rotsaker', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Potatis & rotsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Frukt & Grönt > Kryddor & smaksättare ─────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Smaksättare', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Kryddor & örter', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;
-- ── NIVÅ 3: under Frukt & Grönt > Grönsaker ─────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Bönor & Groddar', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)  SELECT 'Sallad & Kål', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Auberginer & Zucchini', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)  SELECT 'Paprika', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Övriga grönsaker', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Tomater', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Färdigskuret', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Frukt & Grönt > Frukt ─────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Druvor', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Frukt'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Citrusfrukt', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Frukt'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Glass > Chips, snacks & dip ───────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Chips', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Chips, snacks & dip'
  WHERE c1.name = 'Glass, godis & snacks' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Glass > Choklad ───────────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Chokladkakor & rullar', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Choklad'
  WHERE c1.name = 'Glass, godis & snacks' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Kött, chark & fågel > Pålägg ──────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Korv & salami', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Pålägg'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Skivat pålägg', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Pålägg'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Kött, chark & fågel > Chark ─────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Köttbullar & färsprodukter', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Chark'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Kött, chark & fågel > Korv ───────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Ölkorv', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Korv'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Grill, kok- & kryddkorv', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Korv'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Vegetarisk korv', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Korv'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Kött, chark & fågel > Kött ────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Färdiglagat & pannfärdigt', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kött'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Nöt & kalv', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kött'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Köttfärs', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kött'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Fläsk', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kött'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Kött, chark & fågel > Fågel ───────────────
INSERT INTO `Category` (`name`, `parentId`)  SELECT 'Färsk fågel', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Fågel'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)  SELECT 'Fryst fågel', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Fågel'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Mejeri, ost & ägg > Ost ───────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Färskost', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Ost'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Dessertost', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Ost'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Matlagningsost', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Ost'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Mejeri, ost & ägg > Mjölk ─────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Standardmjölk', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Mjölk'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Mejeri, ost & ägg > Allergi mejeri ────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Mjölk', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Allergi mejeri'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Filmjölk & Yoghurt', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Allergi mejeri'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Mejeri, ost & ägg > Mjölk (standard) ───────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Standardmjölk', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Mjölk'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Mejeri, ost & ägg > Matlagning ──────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Gräddfil & creme fraiche', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Matlagning'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Matlagningsyoghurt', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Matlagning'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Mejeri, ost & ägg > Smör, margarin & jäst ────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Matfett', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Smör, margarin & jäst'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Mejeri, ost & ägg > Filmjölk & Yoghurt ────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Filmjölk', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Filmjölk & Yoghurt'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Smaksatt yoghurt', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Filmjölk & Yoghurt'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Mejeri, ost & ägg > Kvarg & Cottage cheese ────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Kvarg', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kvarg & Cottage cheese'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Skafferi > Kryddor & smaksättare ──────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Sås, dressing & majonnäs', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Kryddor', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Övriga smaksättare', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Skafferi > Pasta, ris & matgryn ───────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Färsk pasta', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Pasta, ris & matgryn'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Pasta', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Pasta, ris & matgryn'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Skafferi > Oliver & delikatesser ──────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Delikatesser', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Oliver & delikatesser'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Skafferi > Konserver & burkar ─────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Tomatkonserver', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Konserver & burkar'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Fruktkonserver', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Konserver & burkar'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Grönsakskonserver', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Konserver & burkar'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Fisk- & skaldjurskonserver', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Konserver & burkar'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Skafferi > Asien ──────────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Såser & grytbaser', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Asien'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Nudlar', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Asien'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Skafferi > Torra baljväxter ───────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Fröer & kärnor', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Torra baljväxter'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Skafferi > Flingor, gryner & musli ──────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Granola', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Flingor, gryner & musli'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Fryst > Potatis ──────────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Pommes frites & strips', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Potatis'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Fryst > Färdigmat ────────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Övrig färdigmat', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Färdigmat'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Färdigmat enportioner', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Färdigmat'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Pizza, paj & piroger', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Färdigmat'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Skafferi > Bakning ────────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Baktillbehör', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Bakning'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Fisk & Skaldjur > Fisk ────────────────────
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Fryst fisk', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Fisk'
  WHERE c1.name = 'Fisk & Skaldjur' AND c1.parentId IS NULL;
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Rökt & gravat', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Fisk'
  WHERE c1.name = 'Fisk & Skaldjur' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Fisk & Skaldjur > Sill, Ansjovis & Sardiner 
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Sill', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Sill, Ansjovis & Sardiner'
  WHERE c1.name = 'Fisk & Skaldjur' AND c1.parentId IS NULL;

-- ── NIVÅ 3: under Fisk & Skaldjur > Skaldjur & Havsdelikatesser
INSERT INTO `Category` (`name`, `parentId`)
  SELECT 'Frysta skaldjur & havsdelikatesser', c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Skaldjur & Havsdelikatesser'
  WHERE c1.name = 'Fisk & Skaldjur' AND c1.parentId IS NULL;


-- ============================================================
-- STEG 2: PRODUKTER (INSERT IGNORE — hoppar över befintliga)
-- (från 002-seed-products.sql.disabled)
-- ============================================================

INSERT IGNORE INTO `Product` (`name`, `normalizedName`, `isActive`, `createdAt`, `updatedAt`) VALUES
('Ananas', 'ananas', 1, NOW(), NOW()),
('Anka', 'anka', 1, NOW(), NOW()),
('Ankbröst', 'ankbrost', 1, NOW(), NOW()),
('Apelsin', 'apelsin', 1, NOW(), NOW()),
('Aubergine', 'aubergine', 1, NOW(), NOW()),
('Avokado', 'avokado', 1, NOW(), NOW()),
('Banan', 'banan', 1, NOW(), NOW()),
('Basilika', 'basilika', 1, NOW(), NOW()),
('Blandfärs', 'blandfars', 1, NOW(), NOW()),
('Blomkål', 'blomkal', 1, NOW(), NOW()),
('Bläckfisk', 'blackfisk', 1, NOW(), NOW()),
('Blåbär', 'blabar', 1, NOW(), NOW()),
('Broccoli', 'broccoli', 1, NOW(), NOW()),
('Bröd', 'brod', 1, NOW(), NOW()),
('Buljong', 'buljong', 1, NOW(), NOW()),
('Bönor', 'bonor', 1, NOW(), NOW()),
('Chiliflingor', 'chiliflingor', 1, NOW(), NOW()),
('Chilipulver', 'chilipulver', 1, NOW(), NOW()),
('Chips', 'chips', 1, NOW(), NOW()),
('Choklad', 'choklad', 1, NOW(), NOW()),
('Citron', 'citron', 1, NOW(), NOW()),
('Curry (mild)', 'currymild', 1, NOW(), NOW()),
('Curry (stark)', 'currystark', 1, NOW(), NOW()),
('Dill', 'dill', 1, NOW(), NOW()),
('Druvor', 'druvor', 1, NOW(), NOW()),
('Entrecote', 'entrecote', 1, NOW(), NOW()),
('Falukorv', 'falukorv', 1, NOW(), NOW()),
('Fasan', 'fasan', 1, NOW(), NOW()),
('Fil', 'fil', 1, NOW(), NOW()),
('Fisk', 'fisk', 1, NOW(), NOW()),
('Fläskfilé', 'flaskfile', 1, NOW(), NOW()),
('Fläskkarré', 'flaskkarre', 1, NOW(), NOW()),
('Fläskkotlett', 'flaskkotlett', 1, NOW(), NOW()),
('Fläskrevben', 'flaskrevben', 1, NOW(), NOW()),
('Fläsksidfläsk', 'flasksidflask', 1, NOW(), NOW()),
('Fläskytterfilé', 'flaskytterfile', 1, NOW(), NOW()),
('Fryst dill', 'frystdill', 1, NOW(), NOW()),
('Fryst persilja', 'frystpersilja', 1, NOW(), NOW()),
('Färsk basilika', 'farskbasilika', 1, NOW(), NOW()),
('Färsk chili', 'farskchili', 1, NOW(), NOW()),
('Färsk dill', 'farskdill', 1, NOW(), NOW()),
('Färsk ingefära', 'farskingefara', 1, NOW(), NOW()),
('Färsk koriander', 'farskkoriander', 1, NOW(), NOW()),
('Färsk oregano', 'farskoregano', 1, NOW(), NOW()),
('Färsk persilja', 'farskpersilja', 1, NOW(), NOW()),
('Färsk rosmarin', 'farskrosmarin', 1, NOW(), NOW()),
('Färsk timjan', 'farsktimjan', 1, NOW(), NOW()),
('Glass', 'glass', 1, NOW(), NOW()),
('Grädde', 'gradde', 1, NOW(), NOW()),
('Gräddfil', 'graddfil', 1, NOW(), NOW()),
('Grönkål', 'gronkal', 1, NOW(), NOW()),
('Gurka', 'gurka', 1, NOW(), NOW()),
('Gås', 'gas', 1, NOW(), NOW()),
('Hallon', 'hallon', 1, NOW(), NOW()),
('Havregryn', 'havregryn', 1, NOW(), NOW()),
('Ingefärspulver', 'ingefarspulver', 1, NOW(), NOW()),
('Jordgubbar', 'jordgubbar', 1, NOW(), NOW()),
('Juice', 'juice', 1, NOW(), NOW()),
('Kaffe', 'kaffe', 1, NOW(), NOW()),
('Kakor', 'kakor', 1, NOW(), NOW()),
('Kalkon', 'kalkon', 1, NOW(), NOW()),
('Kalkonfilé', 'kalkonfile', 1, NOW(), NOW()),
('Kalkonfärs', 'kalkonfars', 1, NOW(), NOW()),
('Kalvfilé', 'kalvfile', 1, NOW(), NOW()),
('Kalvkotlett', 'kalvkotlett', 1, NOW(), NOW()),
('Kanelstång', 'kanelstang', 1, NOW(), NOW()),
('Ketchup', 'ketchup', 1, NOW(), NOW()),
('Kex', 'kex', 1, NOW(), NOW()),
('Kikärter', 'kikarter', 1, NOW(), NOW()),
('Kiwi', 'kiwi', 1, NOW(), NOW()),
('Korianderfrön', 'korianderfron', 1, NOW(), NOW()),
('Korv', 'korv', 1, NOW(), NOW()),
('Kryddor', 'kryddor', 1, NOW(), NOW()),
('Kumminsfrön', 'kumminsfron', 1, NOW(), NOW()),
('Kyckling', 'kyckling', 1, NOW(), NOW()),
('Kycklingben', 'kycklingben', 1, NOW(), NOW()),
('Kycklingben (lårben)', 'kycklingbenlarben', 1, NOW(), NOW()),
('Kycklingben (vingben)', 'kycklingbenvingben', 1, NOW(), NOW()),
('Kycklingbröst', 'kycklingbrost', 1, NOW(), NOW()),
('Kycklingfilé', 'kycklingfile', 1, NOW(), NOW()),
('Kycklingfärs', 'kycklingfars', 1, NOW(), NOW()),
('Kycklinggrund', 'kycklinggrund', 1, NOW(), NOW()),
('Kycklinghals', 'kycklinghals', 1, NOW(), NOW()),
('Kycklinghel', 'kycklinghel', 1, NOW(), NOW()),
('Kycklinghjärta', 'kycklinghjarta', 1, NOW(), NOW()),
('Kycklingkarré', 'kycklingkarre', 1, NOW(), NOW()),
('Kycklingklubba', 'kycklingklubba', 1, NOW(), NOW()),
('Kycklingkropp', 'kycklingkropp', 1, NOW(), NOW()),
('Kycklinglever', 'kycklinglever', 1, NOW(), NOW()),
('Kycklinglår', 'kycklinglar', 1, NOW(), NOW()),
('Kycklingmälta', 'kycklingmalta', 1, NOW(), NOW()),
('Kycklingrevben', 'kycklingrevben', 1, NOW(), NOW()),
('Kycklingvinge', 'kycklingvinge', 1, NOW(), NOW()),
('Kålrot', 'kalrot', 1, NOW(), NOW()),
('Köttbullar', 'kottbullar', 1, NOW(), NOW()),
('Köttfärs', 'kottfars', 1, NOW(), NOW()),
('Lammbog', 'lammbog', 1, NOW(), NOW()),
('Lammfärs', 'lammfars', 1, NOW(), NOW()),
('Lammhals', 'lammhals', 1, NOW(), NOW()),
('Lammkotlett', 'lammkotlett', 1, NOW(), NOW()),
('Lammrack', 'lammrack', 1, NOW(), NOW()),
('Lammrevben', 'lammrevben', 1, NOW(), NOW()),
('Lammstek', 'lammstek', 1, NOW(), NOW()),
('Lasagne', 'lasagne', 1, NOW(), NOW()),
('Lax', 'lax', 1, NOW(), NOW()),
('Lime', 'lime', 1, NOW(), NOW()),
('Linser', 'linser', 1, NOW(), NOW()),
('Läsk', 'lask', 1, NOW(), NOW()),
('Lök', 'lok', 1, NOW(), NOW()),
('Macka', 'macka', 1, NOW(), NOW()),
('Majonnäs', 'majonnas', 1, NOW(), NOW()),
('Malen kanel', 'malenkanel', 1, NOW(), NOW()),
('Malet kummin', 'maletkummin', 1, NOW(), NOW()),
('Mango', 'mango', 1, NOW(), NOW()),
('Marmelad', 'marmelad', 1, NOW(), NOW()),
('Mjöl', 'mjol', 1, NOW(), NOW()),
('Mjölk', 'mjolk', 1, NOW(), NOW()),
('Morot', 'morot', 1, NOW(), NOW()),
('Musslor', 'musslor', 1, NOW(), NOW()),
('Must', 'must', 1, NOW(), NOW()),
('Müsli', 'musli', 1, NOW(), NOW()),
('Nötfärs', 'notfars', 1, NOW(), NOW()),
('Nötter', 'notter', 1, NOW(), NOW()),
('Nötterrin', 'notterrin', 1, NOW(), NOW()),
('Olivolja', 'olivolja', 1, NOW(), NOW()),
('Oregano', 'oregano', 1, NOW(), NOW()),
('Ost', 'ost', 1, NOW(), NOW()),
('Ostskivor', 'ostskivor', 1, NOW(), NOW()),
('Oxfile', 'oxfile', 1, NOW(), NOW()),
('Oxhjärta', 'oxhjarta', 1, NOW(), NOW()),
('Oxlever', 'oxlever', 1, NOW(), NOW()),
('Palsternacka', 'palsternacka', 1, NOW(), NOW()),
('Paprika', 'paprika', 1, NOW(), NOW()),
('Paprikapulver', 'paprikapulver', 1, NOW(), NOW()),
('Pasta', 'pasta', 1, NOW(), NOW()),
('Persilja', 'persilja', 1, NOW(), NOW()),
('Pizza', 'pizza', 1, NOW(), NOW()),
('Potatis', 'potatis', 1, NOW(), NOW()),
('Proteinpulver', 'proteinpulver', 1, NOW(), NOW()),
('Purjolök', 'purjolok', 1, NOW(), NOW()),
('Päron', 'paron', 1, NOW(), NOW()),
('Quorn', 'quorn', 1, NOW(), NOW()),
('Renkött', 'renkott', 1, NOW(), NOW()),
('Rimmat kött', 'rimmatkott', 1, NOW(), NOW()),
('Ris', 'ris', 1, NOW(), NOW()),
('Rosmarin', 'rosmarin', 1, NOW(), NOW()),
('Russin', 'russin', 1, NOW(), NOW()),
('Räkor', 'rakor', 1, NOW(), NOW()),
('Råbiff', 'rabiff', 1, NOW(), NOW()),
('Rödbeta', 'rodbeta', 1, NOW(), NOW()),
('Rödlök', 'rodlok', 1, NOW(), NOW()),
('Rökt paprikapulver', 'roktpaprikapulver', 1, NOW(), NOW()),
('Saft', 'saft', 1, NOW(), NOW()),
('Sallad', 'sallad', 1, NOW(), NOW()),
('Salt', 'salt', 1, NOW(), NOW()),
('Selleri', 'selleri', 1, NOW(), NOW()),
('Sill', 'sill', 1, NOW(), NOW()),
('Skinka', 'skinka', 1, NOW(), NOW()),
('Smör', 'smor', 1, NOW(), NOW()),
('Socker', 'socker', 1, NOW(), NOW()),
('Spaghetti', 'spaghetti', 1, NOW(), NOW()),
('Spenat', 'spenat', 1, NOW(), NOW()),
('Stark paprikapulver', 'starkpaprikapulver', 1, NOW(), NOW()),
('Strömming', 'stromming', 1, NOW(), NOW()),
('Svartpeppar', 'svartpeppar', 1, NOW(), NOW()),
('Söt paprikapulver', 'sotpaprikapulver', 1, NOW(), NOW()),
('Sötpotatis', 'sotpotatis', 1, NOW(), NOW()),
('Tartar', 'tartar', 1, NOW(), NOW()),
('Te', 'te', 1, NOW(), NOW()),
('Timjan', 'timjan', 1, NOW(), NOW()),
('Tofu', 'tofu', 1, NOW(), NOW()),
('Tomat', 'tomat', 1, NOW(), NOW()),
('Torkad basilika', 'torkadbasilika', 1, NOW(), NOW()),
('Torkad chili', 'torkadchili', 1, NOW(), NOW()),
('Torkad dill', 'torkaddill', 1, NOW(), NOW()),
('Torkad ingefära', 'torkadingefara', 1, NOW(), NOW()),
('Torkad koriander', 'torkadkoriander', 1, NOW(), NOW()),
('Torkad oregano', 'torkadoregano', 1, NOW(), NOW()),
('Torkad persilja', 'torkadpersilja', 1, NOW(), NOW()),
('Torkad rosmarin', 'torkadrosmarin', 1, NOW(), NOW()),
('Torkad timjan', 'torkadtimjan', 1, NOW(), NOW()),
('Torskrygg', 'torskrygg', 1, NOW(), NOW()),
('Vatten', 'vatten', 1, NOW(), NOW()),
('Vegebullar', 'vegebullar', 1, NOW(), NOW()),
('Vegobitar', 'vegobitar', 1, NOW(), NOW()),
('Vegofärs', 'vegofars', 1, NOW(), NOW()),
('Vegokorv', 'vegokorv', 1, NOW(), NOW()),
('Vildsvin', 'vildsvin', 1, NOW(), NOW()),
('Viltkött', 'viltkott', 1, NOW(), NOW()),
('Vinäger', 'vinager', 1, NOW(), NOW()),
('Vitkål', 'vitkal', 1, NOW(), NOW()),
('Vitlök', 'vitlok', 1, NOW(), NOW()),
('Vitpeppar', 'vitpeppar', 1, NOW(), NOW()),
('Ägg', 'agg', 1, NOW(), NOW()),
('Älgkött', 'algkott', 1, NOW(), NOW());


-- ============================================================
-- STEG 3: KATEGORITILLDELNING (UPDATE — körs alltid, oavsett om produkten är ny eller gammal)
-- (från seed_product_categories.sql)
-- ============================================================

-- Frukt & Grönt > Frukt > Druvor
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Frukt'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Druvor'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Druvor', 'Gröna druvor', 'Röda druvor');

-- Frukt & Grönt > Frukt > Citrusfrukt
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Frukt'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Citrusfrukt'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Apelsin', 'Citron', 'Lime');

-- Frukt & Grönt > Frukt
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Frukt'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Ananas', 'Banan', 'Kiwi', 'Mango', 'Päron');

-- Frukt & Grönt > Färska bär
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Färska bär'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Blåbär', 'Hallon', 'Jordgubbar');

-- Frukt & Grönt > Grönsaker > Tomater
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Tomater'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Tomat');

-- Frukt & Grönt > Grönsaker > Paprika
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Paprika'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Paprika');

-- Frukt & Grönt > Grönsaker > Övriga grönsaker
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Övriga grönsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN (
  'Aubergine', 'Avokado', 'Blomkål', 'Broccoli', 'Grönkål', 'Gurka',
  'Sallad', 'Selleri', 'Spenat', 'Vitkål'
);

-- Frukt & Grönt > Potatis & rotsaker > Lök
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Potatis & rotsaker'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Lök'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Lök', 'Purjolök', 'Rödlök', 'Vitlök');

-- Frukt & Grönt > Potatis & rotsaker > Rotsaker
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Potatis & rotsaker'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Rotsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Kålrot', 'Morot', 'Palsternacka', 'Rödbeta');

-- Frukt & Grönt > Potatis & rotsaker
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Potatis & rotsaker'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Potatis', 'Sötpotatis');

-- Frukt & Grönt > Kryddor & smaksättare > Smaksättare (färska örter)
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Smaksättare'
  WHERE c1.name = 'Frukt & Grönt' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN (
  'Färsk basilika', 'Färsk chili', 'Färsk dill', 'Färsk ingefära',
  'Färsk koriander', 'Färsk oregano', 'Färsk persilja',
  'Färsk rosmarin', 'Färsk timjan'
);

-- Mejeri, ost & ägg > Mjölk
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Mjölk'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Mjölk');

-- Mejeri, ost & ägg > Filmjölk & Yoghurt > Filmjölk
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Filmjölk & Yoghurt'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Filmjölk'
  WHERE c1.name = 'Mejeri, ost & ägg' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Fil');

-- Mejeri, ost & ägg (ingen djupare nivå)
UPDATE `Product` SET `categoryId` = (
  SELECT id FROM `Category`
  WHERE name = 'Mejeri, ost & ägg' AND parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Ägg', 'Grädde', 'Gräddfil', 'Smör');

-- Kött, chark & fågel > Fågel
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Fågel'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN (
  'Anka', 'Ankbröst', 'Fasan', 'Gås',
  'Kalkon', 'Kalkonfilé', 'Kalkonfärs',
  'Kyckling', 'Kycklingben', 'Kycklingben (lårben)', 'Kycklingben (vingben)',
  'Kycklingbröst', 'Kycklingfilé', 'Kycklingfärs', 'Kycklinggrund',
  'Kycklinghals', 'Kycklinghel', 'Kycklinghjärta', 'Kycklingkarré',
  'Kycklingklubba', 'Kycklingkropp', 'Kycklinglever', 'Kycklinglår',
  'Kycklingmälta', 'Kycklingrevben', 'Kycklingvinge'
);

-- Kött, chark & fågel > Kött > Fläsk
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kött'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Fläsk'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN (
  'Fläskfilé', 'Fläskkarré', 'Fläskkotlett',
  'Fläskrevben', 'Fläsksidfläsk', 'Fläskytterfilé'
);

-- Kött, chark & fågel > Kött > Färdiglagat & pannfärdigt
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kött'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Färdiglagat & pannfärdigt'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Köttbullar');

-- Kött, chark & fågel > Kött
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kött'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN (
  'Blandfärs', 'Entrecote',
  'Kalvfilé', 'Kalvkotlett',
  'Köttfärs', 'Lammbog', 'Lammfärs', 'Lammhals', 'Lammkotlett',
  'Lammrack', 'Lammrevben', 'Lammstek',
  'Nötfärs', 'Oxfile', 'Oxhjärta', 'Oxlever',
  'Råbiff', 'Renkött', 'Rimmat kött', 'Tartar',
  'Vildsvin', 'Viltkött', 'Älgkött'
);

-- Kött, chark & fågel > Korv
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Korv'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Falukorv', 'Korv');

-- Kött, chark & fågel > Pålägg > Skivat pålägg
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Pålägg'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Skivat pålägg'
  WHERE c1.name = 'Kött, chark & fågel' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Skinka');

-- Glass, godis & snacks > Choklad
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Choklad'
  WHERE c1.name = 'Glass, godis & snacks' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Choklad');

-- Glass, godis & snacks > Chips, snacks & dip > Chips
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Chips, snacks & dip'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Chips'
  WHERE c1.name = 'Glass, godis & snacks' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Chips');

-- Dryck > Läsk och Energidryck
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Läsk och Energidryck'
  WHERE c1.name = 'Dryck' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Läsk');

-- Dryck (toppnivå)
UPDATE `Product` SET `categoryId` = (
  SELECT id FROM `Category`
  WHERE name = 'Dryck' AND parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Juice', 'Kaffe', 'Must', 'Saft', 'Te', 'Vatten');

-- Fryst > Färdigmat > Pizza, paj & piroger
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Färdigmat'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Pizza, paj & piroger'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Pizza');

-- Fryst > Grönsaker & kryddor > Grönsaker
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Grönsaker & kryddor'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Grönsaker'
  WHERE c1.name = 'Fryst' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Fryst dill', 'Fryst persilja');

-- Skafferi > Pasta, ris & matgryn > Pasta
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Pasta, ris & matgryn'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Pasta'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Lasagne', 'Pasta', 'Spaghetti');

-- Skafferi > Pasta, ris & matgryn
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Pasta, ris & matgryn'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Havregryn', 'Müsli', 'Ris');

-- Skafferi > Kryddor & smaksättare > Kryddor (torkade örter och malda kryddor)
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Kryddor'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN (
  'Basilika', 'Chiliflingor', 'Chilipulver', 'Dill',
  'Ingefärspulver', 'Kanelstång', 'Korianderfrön', 'Kryddor', 'Kumminsfrön',
  'Malen kanel', 'Malet kummin', 'Oregano',
  'Paprikapulver', 'Persilja', 'Rosmarin', 'Salt',
  'Stark paprikapulver', 'Svartpeppar', 'Söt paprikapulver',
  'Rökt paprikapulver', 'Timjan', 'Vitpeppar',
  'Torkad basilika', 'Torkad chili', 'Torkad dill',
  'Torkad ingefära', 'Torkad koriander', 'Torkad oregano',
  'Torkad persilja', 'Torkad rosmarin', 'Torkad timjan'
);

-- Skafferi > Kryddor & smaksättare > Sås, dressing & majonnäs
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Sås, dressing & majonnäs'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Ketchup', 'Majonnäs', 'Vinäger');

-- Skafferi > Kryddor & smaksättare > Övriga smaksättare
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Övriga smaksättare'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Olivolja');

-- Skafferi > Kryddor & smaksättare (ingen djupare nivå)
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Kryddor & smaksättare'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Buljong');

-- Skafferi > Torra baljväxter
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Torra baljväxter'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Bönor', 'Kikärter', 'Linser');

-- Skafferi > Torkad frukt
UPDATE `Product` SET `categoryId` = (
  SELECT c2.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Torkad frukt'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Russin');

-- Skafferi > Bakning > Baktillbehör
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Bakning'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Baktillbehör'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Mjöl', 'Socker');

-- Skafferi > Konserver & burkar > Fruktkonserver
UPDATE `Product` SET `categoryId` = (
  SELECT c3.id FROM `Category` c1
  JOIN `Category` c2 ON c2.parentId = c1.id AND c2.name = 'Konserver & burkar'
  JOIN `Category` c3 ON c3.parentId = c2.id AND c3.name = 'Fruktkonserver'
  WHERE c1.name = 'Skafferi' AND c1.parentId IS NULL
  LIMIT 1
) WHERE `name` IN ('Marmelad');
