---
title: migrations generate
description: Creates migration files for specific components of a Storyblok space.
url: https://www.storyblok.com/docs/tooling/cli/migrations-generate
---

# migrations generate

Creates migration files for specific components of a Storyblok space. Migrations are useful for making changes to existing stories in a Storyblok space, such as updating component structures or content.

> [!NOTE]
> A “migration” is a change to the content in a space matching a change to the underlying schema. For example, if the name of the `title` field changes to `headline`, a migration would reassign all the content of the `title` field to the new `headline` field. This is different from a [CMS migration](/docs/concepts/cms-migration).

The command will recursively generate a folder structure and migration file for the specified component:

```text
.storyblok/
└── migrations/
    └── <space-id>/
        └── <component-name>[.<suffix>].js
```

The generated migration file contains a template function with examples for common transformations. The function receives a `block` parameter that contains the components data. The function should return the updated block.

## Usage

```bash
storyblok migrations generate <component-name> --space <source-space-id> [--suffix <suffix>]
```

## Arguments

| Argument | Type | Description |
| --- | --- | --- |
| Component name | string | _Required._ The technical name of a single component to generate a migration for. |

## Flags

| Flag | Type | Description |
| --- | --- | --- |
| `--space` | integer | _Required._ The ID of the Storyblok space that contains the component to generate a migration for. |
| `--path` | string | _Optional._ Specify a custom path for migration files. Defaults to `.storyblok/migrations/<space-id>`. |
| `--suffix` | string | _Optional._ Specify a custom suffix for migration files. |

## Examples

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

```bash
# Generate a migration for the "hero-section" component in the specified space
storyblok migrations generate hero-section
# Generate a migration for the "hero-section" component in the specified space, saving with a custom suffix
storyblok migrations generate hero-section --suffix dev
```

## Pagination

-   [Previous: logs prune](/docs/tooling/cli/logs-prune)
-   [Next: migrations rollback](/docs/tooling/cli/migrations-rollback)
