From c7705ded34b21803a87b66e04606b6a8c3d81d4d Mon Sep 17 00:00:00 2001 From: Anders Gustafsson <34234789+anders-photowall@users.noreply.github.com> Date: Wed, 13 May 2026 11:00:10 +0200 Subject: [PATCH] 9432 - backfill categories with any new categories_v2_lft_rgt categories (#559) --- migrations/000.631.sql | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 migrations/000.631.sql diff --git a/migrations/000.631.sql b/migrations/000.631.sql new file mode 100644 index 0000000..6c432a7 --- /dev/null +++ b/migrations/000.631.sql @@ -0,0 +1,14 @@ +-- Backfill any category that exists in categories_v2_lft_rgt but is missing +-- from the canonical `categories` table. The canonical table is what +-- product_category references via FK, so every v2 category must have a +-- corresponding row there (with is_v2 = true). +-- +-- This covers categories 1824 and 1825 (created before insertNode was fixed) +-- and any other gaps that may exist. ON CONFLICT makes it safe to re-run. +INSERT INTO categories (id, name, is_v2) +SELECT v2.id, v2.name, true +FROM categories_v2_lft_rgt v2 +WHERE NOT EXISTS ( + SELECT 1 FROM categories c WHERE c.id = v2.id + ) +ON CONFLICT (id) DO NOTHING;