I have a collection, User that has the following schema:
User { "_id": "some_id", "name": "string", "email": "string@example.com"
`}``````
And I would like to change name to full_name .
I wrote a custom migration code that does the change.
Now, for a few entries, the change will not take much time. I am more interested to know how it will affect (in terms of performance, and/or downtime) the database that has, let’s say, 100K users.
I just want to expand on this slightly. Joel’s response about the performance of $rename is accurate, though you’d need to benchmark this to determine how it might impact active workloads in your given environment.
As to “no downtime”, your application would need to already know how to work with a User model with either a name or full_name field, so having some versioning logic within your model would be necessary - and this would need to be defined prior to changing any data.
If your data model expects name and that field is no longer present, even though full_name would now be set, there would be “downtime” while a version of the app was deployed that contained the updated model.
Since your original question mentions “ORM migrations” I’m curious what ORM you’re working with or if this was a generic question?