Runtime changing model with mongodb/mongoid

前端 未结 3 1763
太阳男子
太阳男子 2021-02-03 12:08

I\'ve to add several fields in a mongoid model, I know there is not migration with MongoDB but if I go on without dropping the DB, making rails to \"regenerate\" the DB entirely

3条回答
  •  有刺的猬
    2021-02-03 12:49

    Below is a nice code example for data migration script with mongoid and the ruby mongo driver - to be used when your updated model no longer match production data.

    http://pivotallabs.com/users/lee/blog/articles/1548-mongoid-migrations-using-the-mongo-driver

    I whish we would stop using "no migrations with mongoid" as slogan. It'll turn people to MongoDB for the wrong reasons, and it's only partially true. No schema, true, but data still needs to be maintained, which IMO is harder with MongoDB than RDBMs. There are other, great reasons for choosing MongoDB and it depends on your problem.

提交回复
热议问题