|
| 1 | +================== |
| 2 | +setAllowMigrations |
| 3 | +================== |
| 4 | + |
| 5 | +.. default-domain:: mongodb |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 1 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +Definition |
| 14 | +---------- |
| 15 | + |
| 16 | +.. dbcommand:: setAllowMigrations |
| 17 | + |
| 18 | + .. versionadded:: 5.1.2 |
| 19 | + |
| 20 | + Prevents the start of new :ref:`automatic migrations |
| 21 | + <sharding-chunk-migration-automatic>` on a collection, prevents |
| 22 | + in-flight :ref:`manual migrations <sharding-chunk-migration-manual>` |
| 23 | + from committing, and excludes the collection from new balancer |
| 24 | + rounds. |
| 25 | + |
| 26 | + The command has the following syntax: |
| 27 | + |
| 28 | + .. code-block:: javascript |
| 29 | + |
| 30 | + db.adminCommand( { |
| 31 | + setAllowMigrations: "<db>.<collection>", |
| 32 | + allowMigrations: <true|false> |
| 33 | + } ) |
| 34 | + |
| 35 | + The command takes the following parameters: |
| 36 | + |
| 37 | + .. list-table:: |
| 38 | + :header-rows: 1 |
| 39 | + :widths: 20 20 60 |
| 40 | + |
| 41 | + * - Field |
| 42 | + - Type |
| 43 | + - Description |
| 44 | + |
| 45 | + * - :ref:`setAllowMigrations <setAllowMigrations-cmd-coll>` |
| 46 | + |
| 47 | + - ``string`` |
| 48 | + |
| 49 | + - .. _setAllowMigrations-cmd-coll: |
| 50 | + |
| 51 | + The collection to modify. |
| 52 | + |
| 53 | + * - :ref:`allowMigrations <setAllowMigrations-cmd-flag>` |
| 54 | + |
| 55 | + - ``boolean`` |
| 56 | + |
| 57 | + - .. _setAllowMigrations-cmd-flag: |
| 58 | + |
| 59 | + If ``false``: |
| 60 | + |
| 61 | + - MongoDB prevents new :ref:`automatic migrations |
| 62 | + <sharding-chunk-migration-automatic>` on the collection |
| 63 | + - in-flight :ref:`manual migrations |
| 64 | + <sharding-chunk-migration-manual>` will not be committed |
| 65 | + - the collection will be excluded from new balancer rounds |
| 66 | + |
| 67 | + If ``true``: |
| 68 | + |
| 69 | + - MongoDB allows new :ref:`automatic migrations |
| 70 | + <sharding-chunk-migration-automatic>` on the collection |
| 71 | + - in-flight :ref:`manual migrations |
| 72 | + <sharding-chunk-migration-manual>` will be committed |
| 73 | + - the collection will be included in new balancer rounds |
| 74 | + |
| 75 | +Behavior |
| 76 | +-------- |
| 77 | + |
| 78 | +:dbcommand:`setAllowMigration` requires the same privileges as |
| 79 | +:authaction:`moveChunk`. |
| 80 | + |
| 81 | +Example |
| 82 | +------- |
| 83 | + |
| 84 | +This operation prevents migrations on the ``store.inventory`` |
| 85 | +collection: |
| 86 | + |
| 87 | +.. code-block:: javascript |
| 88 | + |
| 89 | + db.adminCommand( { |
| 90 | + setAllowMigrations: "store.inventory", |
| 91 | + allowMigrations: false |
| 92 | + } ) |
0 commit comments