What's the easiest way to migrate/move/rename the Garden model to a new Parcel model?
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

This code is here. I'm using Rails + Mongoid. I have a Garden model, but I want that to be a Parcel model. Users don't have gardens they have parcels.

Below is repo.
https://github.com/akshatpradhan/parcel

awarded to sguha

Crowdsource coding tasks.

2 Solutions


I'd suggest using
https://github.com/facebook/codemod
for this type of large-scale refactor.

eg:

cd path/to/parcel
codemod --extensions rb,erb,coffee 'garden' 'parcel'
codemod --extensions rb,erb,coffee 'Garden' 'Parcel'
Winning solution
Tipped

I submitted a pull request replacing all references of Garden with Parcel. I also had to rename the Parcel configuration module to ParcelApp to prevent a namespace collision.

Finally, to preserve data, run mongo parcel_development --eval "db.gardens.renameCollection('parcels')" in your terminal window to rename the collection in mongoDB

View Timeline