开发者

How to fix records when models have be updated with mongodb

I have a rails project that uses mongodb, the issue i am having is when i have records (documents) made from a previous model. (i'm gettin klass errors, just for the 开发者_如何学JAVAolder records)

Is there a quick way to fix those mongodb documents the rails way, using some command.

Or is there a command i can run with mongoid for it to open the specific model up in mongo, then i can poke with the document manually (removing unneeded associations).


The concept of schema migration would need to exist in mongoid and I don't think it does. If you have made simple changes like renaming or removing fields then you can easily do that with an update statement, but for anything more complicated you will need to write code.

The code you will need to write will most likely need to go down to the driver level to alter the objects since the mapping layer is no longer compatible.

In general you need to be careful when you make schema changes, in your objects, since the server doesn't have that concept and can't enforce them. It is ultimately up to your code, or the framework you are using, to maintain compatibility.

This is generally an issue when you mapping system without doing batch upgrades to keep things at the same schema, from the mapping layer perspective.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜