Skip to content
Snippets Groups Projects
Commit e5264ede authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Added constraint to avoid orphan nodes

parent 7e36e068
No related branches found
No related tags found
No related merge requests found
Pipeline #1929 passed
......@@ -37,6 +37,7 @@ ALTER TABLE node ADD COLUMN relative_path ltree GENERATED ALWAYS AS (path(parent
CREATE INDEX file_rel_path_gist_idx ON node USING GIST(relative_path);
ALTER TABLE node ADD CONSTRAINT unique_path UNIQUE (parent_path, name);
ALTER TABLE node ADD CONSTRAINT fk_parent_path FOREIGN KEY (parent_path) REFERENCES node(path);
-- Create root node
INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, is_public) VALUES (NULL, NULL, '', 'container', '0', true);
......@@ -4,3 +4,5 @@ CREATE UNIQUE INDEX file_path_idx ON node USING btree(path);
ALTER TABLE node ADD COLUMN relative_path ltree GENERATED ALWAYS AS (path(parent_relative_path, node_id)) STORED;
CREATE INDEX file_rel_path_gist_idx ON node USING GIST(relative_path);
ALTER TABLE node ADD CONSTRAINT fk_parent_path FOREIGN KEY (parent_path) REFERENCES node(path);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment