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;