Runtime changing model with mongodb/mongoid

前端 未结 3 1766
太阳男子
太阳男子 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:48

    It is a little ridiculous to say that you don't need migrations with mongodb or mongoid. Any sophisticated app needs to be refactored from time to time and that can mean pulling fields out of disparate documents into a new one.

    Writing one off rake tasks is way less convenient and error prone than having migrations be part of your deploy script so that it always gets run on every environment.

    https://github.com/adacosta/mongoid_rails_migrations brings AR style migrations to mongoid.

    You might need them less often, but you will certainly need them as an app grows.

提交回复
热议问题