CLI reference
Migration CLI command reference
Create, list, and run content migrations
npx sanity migration --help
pnpm dlx sanity migration --help
yarn dlx sanity migration --help
bunx sanity migration --help
Commands
create
USAGE
$ sanity migration create [TITLE]
ARGUMENTS
[TITLE] Title of migration
DESCRIPTION
Create a new migration within your project
EXAMPLES
Create a new migration, prompting for title and options
sanity migration create
Create a new migration with the provided title, prompting for options
sanity migration create "Rename field from location to address"list
USAGE
$ sanity migration list
DESCRIPTION
List available migrations
EXAMPLES
List all available migrations in the project
sanity migration listrun
USAGE
$ sanity migration run [ID]
ARGUMENTS
[ID] ID
FLAGS
--api-version=<API-VERSION> API version to use when migrating. Defaults to v2024-01-29.
--concurrency=<CONCURRENCY> How many mutation requests to run in parallel. Must be between 1 and 10. Default: 6.
--confirm Prompt for confirmation before running the migration (default: true). Use --no-confirm to skip.
--dataset=<DATASET> Dataset to migrate. Defaults to the dataset configured in your Sanity CLI config.
--dry-run By default the migration runs in dry mode. Use --no-dry-run to migrate dataset.
--from-export=<FROM-EXPORT> Use a local dataset export as source for migration instead of calling the Sanity API. Note: this is only supported for dry runs.
--progress Display progress during migration (default: true). Use --no-progress to hide output.
--project=<PROJECT> Project ID of the dataset to migrate. Defaults to the projectId configured in your Sanity CLI config.
DESCRIPTION
Run a migration against a dataset
EXAMPLES
dry run the migration
sanity migration run <id>
execute the migration against a dataset
sanity migration run <id> --no-dry-run --project xyz --dataset staging
execute the migration using a dataset export as the source
sanity migration run <id> --from-export=production.tar.gz --no-dry-run --project xyz --dataset staging