Moving tasks - Internal dependencies fix
Moving tasks with internal dependencies from a logical container to another will now work, as the dependencies will be re-added automatically.
This commit is contained in:
parent
f23e1e94eb
commit
c69abbe2b3
1 changed files with 48 additions and 22 deletions
|
@ -94,7 +94,9 @@ BEGIN
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
-- If we're changing the LTC, handle dependencies.
|
-- If we're changing the LTC, handle dependencies.
|
||||||
IF _ltc_source <> _ltc_dest AND NOT _force THEN
|
IF _ltc_source <> _ltc_dest THEN
|
||||||
|
-- Start with external dependencies
|
||||||
|
IF NOT _force THEN
|
||||||
-- Check them if we're not forcing the move.
|
-- Check them if we're not forcing the move.
|
||||||
PERFORM _tdn.task_id
|
PERFORM _tdn.task_id
|
||||||
FROM taskdep_nodes _tdn
|
FROM taskdep_nodes _tdn
|
||||||
|
@ -106,7 +108,7 @@ BEGIN
|
||||||
IF FOUND THEN
|
IF FOUND THEN
|
||||||
RETURN 5;
|
RETURN 5;
|
||||||
END IF;
|
END IF;
|
||||||
ELSIF _ltc_source <> _ltc_dest AND _force THEN
|
ELSE
|
||||||
-- Otherwise, break them.
|
-- Otherwise, break them.
|
||||||
DELETE FROM task_dependencies
|
DELETE FROM task_dependencies
|
||||||
WHERE taskdep_id IN (
|
WHERE taskdep_id IN (
|
||||||
|
@ -120,6 +122,23 @@ BEGIN
|
||||||
);
|
);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
|
-- Store all internal dependencies, we'll recreate them after
|
||||||
|
-- the tasks have been moved.
|
||||||
|
SET LOCAL client_min_messages=warning;
|
||||||
|
DROP TABLE IF EXISTS _tm_deps;
|
||||||
|
RESET client_min_messages;
|
||||||
|
CREATE TEMPORARY TABLE _tm_deps(
|
||||||
|
task_id INT ,
|
||||||
|
task_id_depends INT
|
||||||
|
) ON COMMIT DROP;
|
||||||
|
INSERT INTO _tm_deps ( task_id , task_id_depends )
|
||||||
|
SELECT task_id , task_id_depends
|
||||||
|
FROM task_dependencies
|
||||||
|
INNER JOIN _tm_tasks USING ( task_id );
|
||||||
|
DELETE FROM task_dependencies
|
||||||
|
WHERE task_id IN ( SELECT task_id FROM _tm_tasks );
|
||||||
|
END IF;
|
||||||
|
|
||||||
-- We're ready to move the tasks themselves.
|
-- We're ready to move the tasks themselves.
|
||||||
IF _toTask THEN
|
IF _toTask THEN
|
||||||
SELECT INTO _i item_id FROM tasks WHERE task_id = _toId;
|
SELECT INTO _i item_id FROM tasks WHERE task_id = _toId;
|
||||||
|
@ -131,6 +150,13 @@ BEGIN
|
||||||
SELECT task_id FROM _tm_tasks
|
SELECT task_id FROM _tm_tasks
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Restore deleted dependencies
|
||||||
|
IF _ltc_dest <> _ltc_source THEN
|
||||||
|
INSERT INTO task_dependencies ( task_id , task_id_depends , ltc_id )
|
||||||
|
SELECT task_id , task_id_depends , _ltc_dest
|
||||||
|
FROM _tm_deps;
|
||||||
|
END IF;
|
||||||
|
|
||||||
RETURN 0;
|
RETURN 0;
|
||||||
END;
|
END;
|
||||||
$tasks_move$;
|
$tasks_move$;
|
||||||
|
|
Loading…
Reference in a new issue