tasks/database/upgrade/from-bca6b99068cbf1dd4148d6bd5cb60e926162cfe1.sql
Emmanuel BENOîT a9035d5be6 Fixed Move to grandparent/sibling
Moving a subtask to its grandparent, or making a task a sub-task of one
of its siblings, didn't work as expected. While the icons were being
updated correctly, the task didn't appear in the right location. That
was because, while the cached structure was being updated, the task
itself wasn't.
2016-01-02 10:47:36 +01:00

37 lines
726 B
PL/PgSQL

--
-- Upgrade the database from commit ID bca6b99068cbf1dd4148d6bd5cb60e926162cfe1
--
-- Run this from the top-level directory
--
\i database/config.sql
\c :db_name
BEGIN;
DROP FUNCTION IF EXISTS tasks_item_au( ) CASCADE;
CREATE FUNCTION tasks_ltc_au( )
RETURNS TRIGGER
LANGUAGE PLPGSQL
SECURITY DEFINER
AS $tasks_ltc_au$
BEGIN
UPDATE tasks
SET task_id_parent = (
SELECT task_id
FROM logical_task_containers
WHERE ltc_id = NEW.ltc_id )
WHERE task_id = NEW.task_id;
RETURN NEW;
END;
$tasks_ltc_au$;
REVOKE EXECUTE
ON FUNCTION tasks_ltc_au( )
FROM PUBLIC;
CREATE TRIGGER tasks_ltc_au
AFTER UPDATE OF ltc_id ON tasks
FOR EACH ROW EXECUTE PROCEDURE tasks_ltc_au( );
COMMIT;