From 1388e869ae1d9dbd1aa98516604f9a2bf960f388 Mon Sep 17 00:00:00 2001 From: Anders Gustafsson <34234789+anders-photowall@users.noreply.github.com> Date: Mon, 11 May 2026 10:24:18 +0200 Subject: [PATCH] 9366 - add missing id sequence to categories_v2_lft_rgt (#558) --- migrations/000.629.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 migrations/000.629.sql diff --git a/migrations/000.629.sql b/migrations/000.629.sql new file mode 100644 index 0000000..5e7f34c --- /dev/null +++ b/migrations/000.629.sql @@ -0,0 +1,15 @@ +-- Add missing sequence for categories_v2_lft_rgt.id to support auto-increment on insert. +-- This is required by the method we use to insert new category nodes in pw_category_tree.php->insertNode() + +CREATE SEQUENCE IF NOT EXISTS categories_v2_lft_rgt_id_seq + AS bigint + START WITH 1 + INCREMENT BY 1 + CACHE 1; + +SELECT setval('categories_v2_lft_rgt_id_seq', COALESCE((SELECT MAX(id) FROM categories_v2_lft_rgt), 0) + 1, false); + +ALTER TABLE categories_v2_lft_rgt + ALTER COLUMN id SET DEFAULT nextval('categories_v2_lft_rgt_id_seq'::regclass); + +ALTER SEQUENCE categories_v2_lft_rgt_id_seq OWNED BY categories_v2_lft_rgt.id;