mirror of
https://github.com/redmine/redmine.git
synced 2025-11-02 03:15:57 +01:00
Adds .rebuild_single_tree! to rebuild a single tree (#24167).
git-svn-id: http://svn.redmine.org/redmine/trunk@16111 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -183,6 +183,16 @@ module Redmine
|
||||
end
|
||||
end
|
||||
|
||||
def rebuild_single_tree!(root_id)
|
||||
root = Issue.where(:parent_id => nil).find(root_id)
|
||||
transaction do
|
||||
where(root_id: root_id).reorder(:id).lock.ids
|
||||
where(root_id: root_id).update_all(:lft => nil, :rgt => nil)
|
||||
where(root_id: root_id, parent_id: nil).update_all(["lft = ?, rgt = ?", 1, 2])
|
||||
rebuild_nodes(root_id)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def rebuild_nodes(parent_id = nil)
|
||||
|
||||
Reference in New Issue
Block a user