I ran into an issue where we had a tree structure that looked like this:
select title, tree_path from my_table where tree_path <@ '3';
title | tree_path
-----------------------
item A | 3
item B | 3.1.1
item C | 3.1.2
item D | 3.1.3
I somehow lost anything at 3.1 so all tree_path <@ '3.1'
were orphaned.
Is there some sort of constraint I can write that would ensure that a node's ancestors exist?