-
Type:
Bug
-
Resolution: Cannot Reproduce
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.0.4
-
Component/s: JavaScript, Shell
-
None
-
ALL
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
renameCollection works from the shell:
> db.oldName.find(); { "_id" : ObjectId("4df78a754a235ac761000000"), "name" : "user1" } > db.oldName.renameCollection("newName"); { "ok" : 1 } > db.newName.find(); { "_id" : ObjectId("4df78a754a235ac761000000"), "name" : "user1" }
I created a script "upgrade.js":
if(db["oldName"].findOne()) { db["oldName"].renameCollection("newName"); }
and running it creates an empty "newName" collection:
> db.oldName.findOne(); { "_id" : ObjectId("4df78a754a235ac761000000"), "name" : "user1" } > db.newName.findOne(); null
I can workaround this issue by inserting all the records from the old to the new collection and then dropping the old collection, but its not very clean.