-- Add supervisor_worktree_task_id column to tasks table.
-- When set, indicates this task shares the worktree of the specified supervisor task
-- and should NOT have its worktree deleted during cleanup (the supervisor owns the worktree).
ALTER TABLE tasks ADD COLUMN supervisor_worktree_task_id UUID REFERENCES tasks(id) ON DELETE SET NULL;

-- Create index for efficient lookups
CREATE INDEX idx_tasks_supervisor_worktree_task_id ON tasks(supervisor_worktree_task_id) WHERE supervisor_worktree_task_id IS NOT NULL;
