Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d31-5.10.0d32.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/Attic/upgrade-5.10.0d31-5.10.0d32.sql,v diff -u -N --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.10.0d31-5.10.0d32.sql 24 Mar 2021 17:00:08 -0000 1.1.2.1 @@ -0,0 +1,13 @@ +-- +-- Avoid potential loops on site_node parent_ids. A parent_id must be +-- different from the node_id. +-- Note that this constraint is not guaranteed to avoid all loops; +-- it is still possible to create indirect recursive +-- loops but excludes some real-world problems. +-- +-- +-- Reduce the impact of adding a constraint on concurrent updates. +-- See: section on NOT VALID in https://www.postgresql.org/docs/current/sql-altertable.html +-- +ALTER TABLE site_nodes ADD CONSTRAINT site_nodes_parent_id_ck CHECK (node_id <> parent_id) NOT VALID; +ALTER TABLE site_nodes VALIDATE CONSTRAINT site_nodes_parent_id_ck;