Skip to content

Instantly share code, notes, and snippets.

@dob
Created May 31, 2011 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dob/1001063 to your computer and use it in GitHub Desktop.
Save dob/1001063 to your computer and use it in GitHub Desktop.
Migrate to MongoDB sample migration method for places
class CopyPlaceJob
@queue = :general
def self.perform(id)
old_place = ::Place.find(id)
mongo_user = MongoHP::User.first(:conditions => {:old_id => old_place.user_id})
if mongo_user
place = mongo_user.hp_objects.create(:old_id => old_place.id,
:object_type => "Place",
:display_name => old_place.name,
:description => old_place.description,
:phone_number => old_place.phone_number,
:website => old_place.website,
...)
MigrateToMongo.migrate_object_tags(place, old_place)
MigrateToMongo.migrate_object_images(place, old_place)
MigrateToMongo.migrate_object_locations(place, old_place)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment