Defect #12145
closedUpdating Issue parent_id and root_id
0%
Description
I'm trying to set a parent issue of 765 for my child issue, 753.
Here is my code:# Updating Parent Relationships
print "Updating Parent Relationships\n"
pp parent_map
parent_map.each do |key, val|
val.each do |child, parent_ticket|
next unless parent_map[key]
print "child: #{child}\n"
print "parent_ticket: #{parent_ticket}\n"
updateissue = Issue.find(child)
updateissue.root_id = parent_ticket
updateissue.parent_id = parent_ticket
pp updateissue
updateissue.save
print "Updated Issue Parent\n"
STDOUT.flush
end
end
This results in:
@Updating Parent Relationships
{1=>{753=>765}}
child: 753
parent_ticket: 765
<Issue id: 753, tracker_id: 1, project_id: 3, subject: "SUBJECT", description: "Description here", due_date: nil, category_id: 71, status_id: 5, assigned_to_id: 11, priority_id: 5, fixed_version_id: 36, author_id: 23, lock_version: 3, created_on: "2010-01-19 14:14:40", updated_on: "2011-01-20 22:07:11", start_date: "2010-01-25", done_ratio: 0, estimated_hours: nil, parent_id: 765, root_id: 765, lft: 1, rgt: 2, is_private: false>@
This updates the database, but the script fails to continue with "Impossible move, target node cannot be inside moved tree."
When I comment out parent_id it works fine. I've looked through the REST API and it says i need to update parent_issue_id, how would I do this?
Updated by William Reiske over 12 years ago
- Status changed from New to Resolved
Figured it out, sorry about that.
child.update_attributes(:parent_issue_id => parent.id)
Updated by Jean-Philippe Lang over 12 years ago
- Status changed from Resolved to Closed
- Resolution set to Invalid