diff --git a/migration/sql-files/105-update-root-area-and-iteration-path-field.sql b/migration/sql-files/105-update-root-area-and-iteration-path-field.sql index 9c9a638b07..168c3b0a13 100644 --- a/migration/sql-files/105-update-root-area-and-iteration-path-field.sql +++ b/migration/sql-files/105-update-root-area-and-iteration-path-field.sql @@ -1,11 +1,11 @@ --- append ID to non-root iteration and area paths -UPDATE iterations SET path=text2ltree(concat(path, concat('.',replace(cast(id as text), '-', '_')))) WHERE path!='' AND path IS NOT NULL; -UPDATE areas SET path=text2ltree(concat(path, concat('.',replace(cast(id as text), '-', '_')))) WHERE path!='' AND path IS NOT NULL; - -- drop constraints ALTER TABLE iterations DROP CONSTRAINT iterations_name_space_id_path_unique; ALTER TABLE areas DROP CONSTRAINT areas_name_space_id_path_unique; +-- append ID to non-root iteration and area paths +UPDATE iterations SET path=text2ltree(concat(path, concat('.',replace(cast(id as text), '-', '_')))) WHERE path!='' AND path IS NOT NULL; +UPDATE areas SET path=text2ltree(concat(path, concat('.',replace(cast(id as text), '-', '_')))) WHERE path!='' AND path IS NOT NULL; + -- update root iteration and area paths to use converted ids UPDATE iterations SET path=text2ltree(replace(cast(id as text), '-', '_')) WHERE path='' OR PATH IS NULL; UPDATE areas SET path=text2ltree(replace(cast(id as text), '-', '_')) WHERE path='' OR PATH IS NULL;