             url,
             parent_id,
             sort,
-            TO_JSONB(id) AS path,
+            content,
+            '[]'::jsonb || TO_JSONB(id) AS path,
             1 AS depth,
-            CAST(sort AS text) AS pos,
-            LPAD(CAST(sort AS text), 3, '0') AS sortpos,
+            CAST(sort AS text) AS structure,
+            LPAD(CAST(sort AS text), 3, '0') AS pos,
             project_id
         FROM
             page

CREATE INDEX ON tree (sort);
CREATE INDEX ON tree USING GIN (path);
CREATE INDEX ON tree (depth);
CREATE INDEX ON tree (pos);
CREATE INDEX ON tree (sortpos);
CREATE INDEX ON tree (project_id);

-- -----------------------------------------------------------

            p.url,
            p.parent_id,
            p.sort,
            p.content,
            t.path || TO_JSONB(p.id) AS path,
            t.depth + 1 AS depth,
            t.structure || '.' || CAST(p.sort AS text) AS structure,
            t.pos || '.' || LPAD(CAST(p.sort AS text), 3, '0') AS pos,
            p.project_id
        FROM
            page p
