diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-05-25 11:37:12 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-05-25 11:37:12 +0000 |
commit | 481f70d12537333206199b4a8d2891218959f4ad (patch) | |
tree | 901e580d30bbb87c2f43716574c29483f0dcac16 /db/migrate | |
parent | 4f8bf001302f6e3e4fabe33b86891ec6581e867b (diff) | |
download | redmine-481f70d12537333206199b4a8d2891218959f4ad.tar.gz redmine-481f70d12537333206199b4a8d2891218959f4ad.zip |
Don't store total estimated hours on parent issues (#16092).
Parent can now have its own estimate that is summed up with children estimates.
git-svn-id: http://svn.redmine.org/redmine/trunk@14272 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb b/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb new file mode 100644 index 000000000..8eed815f7 --- /dev/null +++ b/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb @@ -0,0 +1,15 @@ +class ClearEstimatedHoursOnParentIssues < ActiveRecord::Migration + def self.up + # Clears estimated hours on parent issues + Issue.where("rgt > lft + 1 AND estimated_hours > 0").update_all :estimated_hours => nil + end + + def self.down + table_name = Issue.table_name + leaves_sum_select = "SELECT SUM(leaves.estimated_hours) FROM #{table_name} leaves" + + " WHERE leaves.root_id = #{table_name}.root_id AND leaves.lft > #{table_name}.lft AND leaves.rgt < #{table_name}.rgt" + + " AND leaves.rgt = leaves.lft + 1" + + Issue.where("rgt > lft + 1").update_all "estimated_hours = (#{leaves_sum_select})" + end +end |