OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/db/migrate/20130925090243_cost_reports...

31 lines
801 B

class CostReportsMigration < ActiveRecord::Migration
class CostQuery < ActiveRecord::Base
serialize :serialized, Hash
end
def up
migrate_cost_queries({ "TrackerId" => "TypeId",
"IssueId" => "WorkPackageId" })
end
def down
migrate_cost_queries({ "TypeId" => "TrackerId",
"WorkPackageId" => "IssueId" })
end
private
def migrate_cost_queries(mapping)
CostQuery.find_each do |cost_query|
query = cost_query.serialized
[query[:filters], query[:group_bys]].each do |expression|
expression.each do |term|
attribute_mapping = mapping[term[0]]
term[0] = attribute_mapping if attribute_mapping
end
end
cost_query.save!
end
end
end