[SERVER-104] Allow to rename an existing collection Created: 12/Jun/09  Updated: 12/Jul/16  Resolved: 30/Jul/09

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: None
Fix Version/s: 0.9.8

Type: Improvement Priority: Major - P3
Reporter: Niko Schmuck Assignee: Aaron Staple
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

-


Participants:

 Description   

For administration purposes it would be of great if you can easily rename a MongoDB collection with the help of shell command.



 Comments   
Comment by Roman Gaufman [ 21/Jan/16 ]

This seems to be missing in Mongoid 5 – I used to be able to do:

Mongoid::Sessions.default[:servers].rename(:agents)

But I cannot find any way to do this any more?

Comment by Eliot Horowitz (Inactive) [ 15/Aug/09 ]

Released in 0.9.8

Comment by Aaron Staple [ 30/Jul/09 ]

Ok, I've implemented fast renaming.

Comment by Aaron Staple [ 07/Jul/09 ]

I can take a look next week to see how long it'll take. Probably not more than a day.

Comment by Eliot Horowitz (Inactive) [ 07/Jul/09 ]

can you make an efficient rename within a db? or is that a huge project?

Comment by Aaron Staple [ 07/Jul/09 ]

I believe there is already a 'rename' or 'renameCollection' command implemented, however it makes a completely new copy of a collection and then deletes the old copy which could be considered inefficient. Also, there may not be a convenient shell wrapper.

Comment by Eliot Horowitz (Inactive) [ 12/Jun/09 ]

> db.$cmd.findOne(

{ renameCollection: 'test.foo', to: 'test.b' }

)

Generated at Thu Feb 08 02:53:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.