Database Manual / Reference / Database Commands / Sharding

setAllowMigrations (database command)

Definition

setAllowMigrations

Prevents the start of new automatic migrations on a collection, prevents in-flight range migrations (started manually or by the balancer) from committing, and excludes the collection from new balancer rounds.

Compatibility

This command is available in deployments hosted in the following environments:

  • MongoDB Atlas: The fully managed service for MongoDB deployments in the cloud

Syntax

The command has the following syntax:

db.adminCommand(
{
setAllowMigrations: "<db>.<collection>",
allowMigrations: <true|false>
}
)

Command Fields

The command takes the following parameters:

FieldTypeDescription

setAllowMigrations

string

The collection to modify.

allowMigrations

boolean

If false:

If true:

Behavior

setAllowMigrations requires the same privileges as moveChunk.

Example

This operation prevents migrations on the store.inventory collection:

db.adminCommand( {
setAllowMigrations: "store.inventory",
allowMigrations: false
} )