<i id='OCXMH'><tr id='OCXMH'><dt id='OCXMH'><q id='OCXMH'><span id='OCXMH'><b id='OCXMH'><form id='OCXMH'><ins id='OCXMH'></ins><ul id='OCXMH'></ul><sub id='OCXMH'></sub></form><legend id='OCXMH'></legend><bdo id='OCXMH'><pre id='OCXMH'><center id='OCXMH'></center></pre></bdo></b><th id='OCXMH'></th></span></q></dt></tr></i><div id='OCXMH'><tfoot id='OCXMH'></tfoot><dl id='OCXMH'><fieldset id='OCXMH'></fieldset></dl></div>

    1. <legend id='OCXMH'><style id='OCXMH'><dir id='OCXMH'><q id='OCXMH'></q></dir></style></legend>
        <bdo id='OCXMH'></bdo><ul id='OCXMH'></ul>

      <tfoot id='OCXMH'></tfoot>

        <small id='OCXMH'></small><noframes id='OCXMH'>

      1. 是否有任何用于 NoSQL 数据库架构迁移的工具?

        时间:2023-09-14

          <bdo id='ZISvk'></bdo><ul id='ZISvk'></ul>
          <legend id='ZISvk'><style id='ZISvk'><dir id='ZISvk'><q id='ZISvk'></q></dir></style></legend>

          1. <tfoot id='ZISvk'></tfoot>
            <i id='ZISvk'><tr id='ZISvk'><dt id='ZISvk'><q id='ZISvk'><span id='ZISvk'><b id='ZISvk'><form id='ZISvk'><ins id='ZISvk'></ins><ul id='ZISvk'></ul><sub id='ZISvk'></sub></form><legend id='ZISvk'></legend><bdo id='ZISvk'><pre id='ZISvk'><center id='ZISvk'></center></pre></bdo></b><th id='ZISvk'></th></span></q></dt></tr></i><div id='ZISvk'><tfoot id='ZISvk'></tfoot><dl id='ZISvk'><fieldset id='ZISvk'></fieldset></dl></div>
              <tbody id='ZISvk'></tbody>

              <small id='ZISvk'></small><noframes id='ZISvk'>

                • 本文介绍了是否有任何用于 NoSQL 数据库架构迁移的工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在寻找一种为 MongoDB 或 CouchDB 等数据库自动迁移架构的方法.

                  I'm looking a way to automate schema migration for such databases like MongoDB or CouchDB.

                  这个工具最好是用python写的,其他任何语言都可以.

                  Preferably, this instument should be written in python, but any other language is ok.

                  推荐答案

                  由于 nosql 数据库可以包含大量数据,因此您无法在常规 rdbms 中迁移它.实际上,一旦您的数据超过某个大小阈值,您就无法为 rdbms 执行此操作.让您的网站停工一天以将字段添加到现有表是不切实际的,因此使用 rdbms 您最终会做丑陋的补丁,例如仅为该字段添加新表并进行连接以获取数据.在 nosql 世界中你可以做几件事.

                  Since a nosql database can contain huge amounts of data you can not migrate it in the regular rdbms sence. Actually you can't do it for rdbms as well as soon as your data passes some size threshold. It is impractical to bring your site down for a day to add a field to an existing table, and so with rdbms you end up doing ugly patches like adding new tables just for the field and doing joins to get to the data. In nosql world you can do several things.

                  • 正如其他人建议的那样,您可以编写代码,以便处理可能架构的不同版本".这通常比看起来更简单.许多类型的模式更改对代码来说都是微不足道的.例如,如果您想向架构中添加一个新字段,您只需将其添加到所有新记录中,所有旧记录上它都将为空(您不会收到字段不存在"错误或任何内容;).如果您需要旧记录中的字段的默认"值,则在代码中太简单了.
                  • 另一个选项,实际上唯一明智的选择是在字段重命名和结构更改等非平凡的架构更改中存储 schema_version 在每个记录中,并使用代码将数据从任何版本迁移到 上的下一个版本阅读.即,如果您当前的架构版本是 10,并且您从数据库中读取版本为 7 的记录,那么您的数据库层应该调用 migrate_8、migrate_9 和 migrate_10.这样访问的数据会逐渐迁移到新版本.如果它没有被访问,那么谁在乎它是哪个版本;)
                  • As others suggested you can write your code so that it will handle different 'versions' of the possible schema. this is usually simpler then it looks. Many kinds of schema changes are trivial to code around. for example if you want to add a new field to the schema, you just add it to all new records and it will be empty on the all old records (you will not get "field doesn't exist" errors or anything ;). if you need a 'default' value for the field in the old records it is too trivially done in code.
                  • Another option and actually the only sane option going forward with non-trivial schema changes like field renames and structural changes is to store schema_version in EACH record, and to have code to migrate data from any version to the next on READ. i.e. if your current schema version is 10 and you read a record from the database with the version of 7, then your db layer should call migrate_8, migrate_9, and migrate_10. This way the data that is accessed will be gradually migrated to the new version. and if it is not accessed, then who cares which version is it;)

                  这篇关于是否有任何用于 NoSQL 数据库架构迁移的工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何通过 Python 访问 Amazon DynamoDB? 下一篇:用于 Web 照片库的正确 NoSQL 数据架构

                  相关文章

                  最新文章

                  <i id='zVt7d'><tr id='zVt7d'><dt id='zVt7d'><q id='zVt7d'><span id='zVt7d'><b id='zVt7d'><form id='zVt7d'><ins id='zVt7d'></ins><ul id='zVt7d'></ul><sub id='zVt7d'></sub></form><legend id='zVt7d'></legend><bdo id='zVt7d'><pre id='zVt7d'><center id='zVt7d'></center></pre></bdo></b><th id='zVt7d'></th></span></q></dt></tr></i><div id='zVt7d'><tfoot id='zVt7d'></tfoot><dl id='zVt7d'><fieldset id='zVt7d'></fieldset></dl></div>

                  <tfoot id='zVt7d'></tfoot>

                  <small id='zVt7d'></small><noframes id='zVt7d'>

                      <bdo id='zVt7d'></bdo><ul id='zVt7d'></ul>
                    1. <legend id='zVt7d'><style id='zVt7d'><dir id='zVt7d'><q id='zVt7d'></q></dir></style></legend>