diff --git a/migrations/000.638.sql b/migrations/000.638.sql new file mode 100644 index 0000000..207cc60 --- /dev/null +++ b/migrations/000.638.sql @@ -0,0 +1,11 @@ +-- Align legacy ancestor view with v2 behavior by excluding root category id = 1. +CREATE OR REPLACE VIEW v_category_with_ancestors AS +SELECT c.id, + parent.id AS ancestor_id, + parent.name +FROM categories c +LEFT JOIN categories parent + ON parent.lft <= c.lft + AND parent.rgt >= c.rgt + AND parent.id <> 1 +WHERE c.id <> 1;