Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
sql
sql
titleSQL to check for orphan tree references
SELECT *
FROM nested_tree_objects
WHERE 
parentid NOT IN (SELECT objectid FROM nested_tree_objects)
AND parentid <> ''

Rather than deleting everything you could just find the object references a new parent!

Code Block
sql
sql
titleSQL to check for orphan tree references

UPDATE nested_tree_objects
SET
parentid='--some UUID of valid parent--'
WHERE
objectid IN (select objectid from nested_tree_objects
		where 
		parentid NOT IN (select objectid from nested_tree_objects))
		AND (parentid is not null or parentid <> '')