Handling migrations with MongoDb

后端 未结 3 1319
栀梦
栀梦 2020-12-31 06:05

Just to give a little more context to the question, I have a web application (asp mvc) which basically wraps CRUD operations to a MongoDb instance, it carries out validation

3条回答
  •  说谎
    说谎 (楼主)
    2020-12-31 06:52

    There are basically two approaches:

    1. Make sure that your application code can handle both "versions" of the data structure, and when saving, updates to the new structure
    2. Write a migration script

    I would probably go for option 1 as it's the method that allows you to gradually update, where as with option 2 you basically need to take down your application so that you can update the code (fast) and data (possibly slower) in one go.

    Then later, or if you find it necessary do option 2 as well to migrate your data over. This then doesn't have to take down your site, and can happily run asynchronously in the background.

提交回复
热议问题