You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 19, 2026. It is now read-only.
When you run this command, a folder called `migrations` will be created in the location where you ran the command (if this folder does not exist) and a file called `change_product_price.js` will be created inside it.
184
+
185
+
The created file will have the following content:
186
+
187
+
```js
188
+
// here, 'subtitle' is the name of the field defined when you execute the generate command
189
+
module.exports=function (block) {
190
+
// Example to change a string to boolean
191
+
// block.subtitle = !!(block.subtitle)
192
+
193
+
// Example to transfer content from other field
194
+
// block.subtitle = block.other_field
195
+
}
196
+
```
197
+
198
+
As you can see, this file takes two parameters:
199
+
200
+
*`block`: the component content from the story
201
+
*`field`: the field content from this component
202
+
203
+
Inside the migration function, you can manipulate the blok whatever you want, because the blok content will be used to update the story. This will be occurr recursively for all content in the story, so, this change will be affect the entirely content.
204
+
205
+
### Running the migration file
206
+
207
+
To run the migration function, you need to execute the `run-migration` command, as the following:
208
+
209
+
```sh
210
+
# you can use the --dryrun option to don't execute, only show the component updates
Let's create an example to update all occurrences of the image field in product component. Let's replace the url from `//a.storyblok.com` to `//my-custom-domain.com`.
Check out our guides for client side apps (VueJS, Angular, React, ...), static site (Jekyll, NuxtJs, ...), dynamic site examples (Node, PHP, Python, Laravel, ...) on our [Getting Started](https://www.storyblok.com/getting-started) page.
0 commit comments