Commit 74fd0219 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Added unique path constraint

parent 57b0f3f8
Loading
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -36,5 +36,7 @@ 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 unique_path UNIQUE (parent_path, name);

-- Create root node
INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, is_public) VALUES (NULL, NULL, '', 'container', '0', true);