---
title: migrations run
description: Executes migration files for specific components in a Storyblok space, updating stories that use those components based on the defined migrations.
url: https://www.storyblok.com/docs/tooling/cli/migrations-run
---

# migrations run

Executes migration files for specific components in a Storyblok space, updating stories that use those components based on the defined migrations. Generates a component-specific snapshot of the space before applying the migrations to allow for rollback if needed.

## Prerequisites

-   Migration files generated by `migrations generate` and updated with the desired changes must be present in the expected directory.

## Usage

```bash
storyblok migrations run [arguments] [flags]
```

## Arguments

| Argument | Type | Description |
| --- | --- | --- |
| Component name | string | _Optional._ The technical name of a single component to run the migration for. If omitted, all migrations found in the specified path are run in the space. |

## Flags

| Flag | Type | Description |
| --- | --- | --- |
| `--space`, `-s` | integer | _Required._ The ID of the Storyblok space to run migrations for. |
| `--filter`, `-fi` | string | _Optional._ Glob pattern to filter stories by their component name (e.g., `hero*` will match all stories starting with `hero`). |
| `--dry-run`, `-d` | boolean | _Optional._ Preview changes without applying them. |
| `--query`, `-q` | string | _Optional._ Filter stories using [query parameters](/docs/api/management/stories/retrieve-multiple-stories#query-parameters). |
| `--starts-with`, `-sw` | string | _Optional._ A path prefix to filter stories to migrate. |
| `--publish` | string | _Optional._ Specify a publication mode: `all` (publish all stories), `published` (only publish stories that were already published), or `published-with-changes` (only publish stories that have unpublished changes). |
| `--path`, `-p` | string | _Optional._ Specify a custom path for migration files. Defaults to `.storyblok/migrations/<space-id>`. |

## Examples

The following examples assume that a `space` has been defined in a configuration file.

```bash
# Run migration for the "hero-section" component in the specified space
storyblok migrations run hero-section
# Run all migrations in the specified space, filtering by component name and previewing changes without applying them
storyblok migrations run --filter "hero-*" --dry-run
# Run all migrations in the specified space, filtering by query and publishing stories that were already published
storyblok migrations run --publish published --query "[highlighted][in]=true"
```

## Pagination

-   [Previous: migrations rollback](/docs/tooling/cli/migrations-rollback)
-   [Next: reports list](/docs/tooling/cli/reports-list)
