Details
-
Bug
-
Status: Closed
-
Major - P3
-
Resolution: Cannot Reproduce
-
2.0.4
-
None
-
None
-
ALL
Description
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.