Skip to content

Instantly share code, notes, and snippets.

@aavegmit
Created February 17, 2012 01:34
Show Gist options
  • Save aavegmit/1849650 to your computer and use it in GitHub Desktop.
Save aavegmit/1849650 to your computer and use it in GitHub Desktop.
class RenameWeightedQualityScore < Mongoid::Migration
def self.up
members.find('_type' => 'Member').each do |member_hash|
members.update({ '_id' => member_hash['_id'] },
{ "$unset" => { "weighted_quality_score" => true },
"$set" => { "decayed_quality_points_total" => member_hash['weighted_quality_score'] } })
end
crowd_members.each do |crowd_member_hash|
crowd_members.update({ '_id' => crowd_member_hash['_id'] },
{ "$unset" => { "weighted_quality_score" => true },
"$set" => { "decayed_quality_points_total" => crowd_member_hash['weighted_quality_score'] } })
end
end
def self.down
members.find('_type' => 'Member').each do |member_hash|
members.update({ '_id' => member_hash['_id'] },
{ "$unset" => { "decayed_quality_points_total" => true },
"$set" => { "weighted_quality_score" => member_hash['decayed_quality_points_total'] } })
end
crowd_members.each do |crowd_member_hash|
crowd_members.update({ '_id' => crowd_member_hash['_id'] },
{ "$unset" => { "decayed_quality_points_total" => true },
"$set" => { "weighted_quality_score" => crowd_member_hash['decayed_quality_points_total'] } })
end
end
def self.members
connection.collection('users')
end
def self.crowd_members
connection.collection('crowd_members')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment