0
我打算迁移旧数据库字段rake任务到Hash
:迁移蒙戈数据与耙状任务
task :degrees => :environment do
Person.all.each do |p|
if p['degree1'] || p['degree2']
p.degrees = {}
p.degrees["first"] = p['degree1'] == "Other" ? p['degree1_other'] : p['degree1']
p.degrees["second"] = p['degree2'] == "Other" ? p['degree2_other'] : p['degree2']
p.save
end
end
end
麻烦的是它与蒙戈和红宝石占80%和20%的CPU速度极慢分别。
对于比较简单的迁移,我能够使用蒙戈更新,像这样:
db.people.update({},{$rename : {"url" : "website"}}, false, true)
这跑速度极快。有没有办法将上面的rake任务转换成mongo更新或shell脚本?
如果您想要轻松地使用Ruby和port编写js mongo,请从调试器中获取mongo命令(如果您设置为调试级别)。 – jcollum