Sha256: f006b00092996f98d5843b12ede98522cc291c382085ce0c9b1c5ae7e150c6d7

Contents?: true

Size: 629 Bytes

Versions: 34

Compression:

Stored size: 629 Bytes

Contents

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

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
redmine_extensions-0.0.39 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.0.38 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.0.37 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.11 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.10 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.0.36 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.0.34 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.09 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.07 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.06 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.05 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.04 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.03 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.0.33 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.02 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.1.01 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.0.29 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.0.28 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.0.27 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb
redmine_extensions-0.0.24 spec/redmine/db/migrate/20150525103953_clear_estimated_hours_on_parent_issues.rb