How to Change Content Models Without Losing Content on a Live Prismic Site
blog · changing-content-models-on-a-live-site
text_content default
- content
The content models you design at launch rarely stay the same as your website matures. Designs evolve, and your content team asks for things the original models can't do. By then, the pages are full of published content.
In Prismic, content is tied to fields, so renaming a field or changing its type risks losing that content. Luckily, this is nothing to worry about with the right techniques.
This guide shows how to apply content model changes you are most likely to encounter.
callout info
- title
Working with an AI agent? Point it here.
- content
Give your coding agent the link to this post, and it can handle these changes for you. Tools like Claude, Codex, and Cursor follow the techniques below to move your content without dropping any of it.
- hidden_content
[]
text_content default
- content
Tools we'll be using
We'll use the Prismic CLI to make model changes throughout this guide. If you prefer a visual interface, you can use your repository's Type Builder. If your project still uses Slice Machine, migrate to the Type Builder first. It takes a few minutes.
text_content default
- content
Change a field's name
Sometimes you need to change a field's name. For example, a Title field might need a clearer name, like Page Title. To do this, change the field's label but keep its ID. Content is locked to the ID, so changing it means losing the content.
Here's how to do this with the Prismic CLI. Note that the field's ID (`title`) doesn't change.
code_snippet default
text_content default
- content
No changes are needed in the website's code since the field ID doesn't change.
Change a field's type
Sometimes you need to change a field's type. For example, a plain text field might need to be converted to a rich text field to support formatting. You can't change a field's type in place, since that would lose the field's content.
Instead, add a new field, move the content into it, switch your code to it, then remove the old field. The old field stays in place the whole time, so your live site keeps working.
callout tip
- title
Best done with AI
- content
This kind of field change, and every later technique that uses the Migration API, is best done with AI tools like Claude, Codex, and Cursor. Content changes can be complex, and AI tools handle them well.
- hidden_content
[]
text_content default
- content
In this example, we'll change a Description field from plain text to rich text that accepts basic formatting.
1. Add the new field
First, add the new field next to the old one. Give it a new ID, like `description_v2`. The old `description` field stays untouched.
code_snippet default
text_content default
- content
2. Move the content over
Next, port the existing content into the new field with a migration script. You'll need a Prismic authentication token to use the Migration API. You can create one like this:
code_snippet default
text_content default
- content
Save the token in a `.env` file like this:
code_snippet default
text_content default
- content
Now write the migration script in a `migrate.js` file:
code_snippet default
text_content default
- content
Run it with Node:
code_snippet default
text_content default
- content
This adds the content to a Migration Release as drafts. Open the release in your Prismic repository and review the changes. Make sure the new field contains the content you expect. If it looks good, publish the release.
3. Switch your code to the new field
Your pages now have both fields. Update your code to read the new one. Here we swap `description` for `description_v2` and render it with the `<PrismicRichText>` component:
code_snippet default
text_content default
- content
Merge your code changes into production.
4. Remove the old field
Finally, once nothing uses the old field, remove it with the Prismic CLI:
code_snippet default
text_content default
- content
Split a field into two
Sometimes you need to split one field into two. For example, a single Name field might need to become separate First Name and Last Name fields so each can be used on its own.
1. Add the new fields
Add two text fields next to the old one:
code_snippet default
text_content default
- content
2. Move the content over
Split each page's name into the two new fields. You'll need a Prismic authentication token to use the Migration API. You can create one like this:
code_snippet default
text_content default
- content
Save the token in a `.env` file like this:
code_snippet default
text_content default
- content
Now write the migration script in a `migrate.js` file:
code_snippet default
text_content default
- content
Run it with Node:
code_snippet default
text_content default
- content
Then review and publish the Migration Release in Prismic.
3. Switch your code
Read the two new fields instead of the old one:
code_snippet default
text_content default
- content
Merge your code changes into production.
4. Remove the old field
Once nothing uses it, remove the old field:
code_snippet default
text_content default
- content
Make a single field repeatable
Sometimes you need to make a single field repeatable. For example, a blog post might link to one Author through a content relationship and later need to credit several authors. Most fields can't be repeated on their own, so add a repeatable group that holds the field, move the content into it, switch your code, then remove the old field.
1. Add the repeatable group
Add a group field, then add the content relationship inside it. The old `author` field stays untouched.
code_snippet default
text_content default
- content
2. Move the content over
Move each blog post's author into the group. You'll need a Prismic authentication token to use the Migration API. You can create one like this:
code_snippet default
text_content default
- content
Save the token in a `.env` file like this:
code_snippet default
text_content default
- content
Now write the migration script in a `migrate.js` file:
code_snippet default
text_content default
- content
Run it with Node:
code_snippet default
text_content default
- content
Then review and publish the Migration Release in Prismic.
3. Switch your code
Map over the group instead of reading the single field:
code_snippet default
text_content default
- content
Merge your code changes into production.
4. Remove the old field
Once nothing uses it, remove the old field:
code_snippet default
text_content default
- content
Plain links are the exception. A plain link field can be made repeatable in place without losing content, but a content relationship like the `author` field above can't. Prismic keeps the existing value and serves it as a list with one item, so you can skip the steps above. Edit the field:
code_snippet default
text_content default
- content
Then update your code to map over the list:
code_snippet default
text_content default
- content
Change the design of a slice
Sometimes you need to redesign a slice variation that already has content. For example, a `call_to_action` slice's `withButton` variation might need different fields for a new layout. Changing the variation in place would break every published page that uses it, so add a new variation alongside it, like `withButtonV2`.
There's no migration script this time. Keep the old variation in place and let content writers move pages to the new variation as they go, starting with the most important ones. Moving every page at once risks breaking layouts no one has reviewed, and most pages may not need the new design. Porting the important pages by hand keeps the risk low and the work small.
1. Add the new variation
Add the new variation to the slice, then model its new fields. The old `withButton` variation stays untouched.
code_snippet default
text_content default
- content
2. Build the new design
Render the new variation in your slice component:
code_snippet default
text_content default
- content
Merge your code changes into production.
3. Steer content writers to the new variation
Relabel the old variation so content writers reach for the new one:
code_snippet default
text_content default
- content
Content writers can now switch important pages to the new variation when they edit them. Pages that still use the old variation keep working.
Once no page uses the old variation, you can remove it:
code_snippet default
text_content default
- content
Wrap-up
The techniques in this guide share a few guidelines:
- Add new fields freely; they don't affect existing content.
- Use the Migration API to move content into the new fields.
- Remove old fields only after migrating the content and updating your code.
These guidelines apply to any model change, not just the ones in this guide. Whatever you're changing, your published content stays intact and your website stays online.
To learn more about the tools used in this guide, see the Prismic documentation:
- Prismic CLI: The commands used to model and push your changes.
- Migrate to Prismic: How to write and run a migration script with the Migration API.
- Content modeling: How model changes, including removals, affect published content.
Document data
{
"title": [
{
"type": "heading1",
"text": "How to Change Content Models Without Losing Content on a Live Prismic Site",
"spans": [],
"direction": "ltr"
}
],
"image": {
"dimensions": {
"width": 516,
"height": 290
},
"alt": null,
"copyright": null,
"url": "https://prismic-main.cdn.prismic.io/prismic-main/aPHx7P64DajQdtIx_developer_workflow.svg",
"id": "aPHx7P64DajQdtIx",
"edit": {
"x": 0,
"y": 0,
"zoom": 1,
"background": "transparent"
}
},
"author": {
"id": "ZO8HtREAACwARj88",
"type": "blog_author",
"tags": [],
"lang": "en-eu",
"slug": "angelo-ashmore",
"first_publication_date": "2023-08-30T09:19:09+0000",
"last_publication_date": "2026-06-25T19:15:29+0000",
"uid": "angelo-ashmore",
"link_type": "Document",
"key": "6f51304e-a683-49c4-9534-6bb388b32ed3",
"isBroken": false
},
"additional_author": {
"link_type": "Document"
},
"category": {
"id": "ZO8gexEAACgARqgP",
"type": "blog_category",
"tags": [],
"lang": "en-eu",
"slug": "developer-workflow",
"first_publication_date": "2023-08-30T10:57:21+0000",
"last_publication_date": "2026-04-22T11:48:11+0000",
"uid": "developer-workflow",
"link_type": "Document",
"key": "3cbfd58b-3a68-40f0-b731-7ec4b4a28226",
"isBroken": false
},
"date": "2026-07-15",
"updated_date": null,
"learning_objective": null,
"card_description": [],
"slices": [
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "The content models you design at launch rarely stay the same as your website matures. Designs evolve, and your content team asks for things the original models can't do. By then, the pages are full of published content.",
"spans": [
{
"start": 4,
"end": 18,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/content-modeling",
"target": "_blank"
}
}
],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "In Prismic, content is tied to fields, so renaming a field or changing its type risks losing that content. Luckily, this is nothing to worry about with the right techniques.",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "This guide shows how to apply content model changes you are most likely to encounter.",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$fa655e88-cf35-4316-8ac4-ef0762d75b04",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "info",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"title": [
{
"type": "heading2",
"text": "Working with an AI agent? Point it here.",
"spans": [],
"direction": "ltr"
}
],
"content": [
{
"type": "paragraph",
"text": "Give your coding agent the link to this post, and it can handle these changes for you. Tools like Claude, Codex, and Cursor follow the techniques below to move your content without dropping any of it.",
"spans": [],
"direction": "ltr"
}
],
"hidden_content": []
},
"id": "callout$18547358-a7db-4f39-8771-346e5fb9911a",
"slice_type": "callout",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading2",
"text": "Tools we'll be using",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "We'll use the Prismic CLI to make model changes throughout this guide. If you prefer a visual interface, you can use your repository's Type Builder. If your project still uses Slice Machine, migrate to the Type Builder first. It takes a few minutes.",
"spans": [
{
"start": 14,
"end": 25,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/cli",
"target": "_blank"
}
},
{
"start": 135,
"end": 147,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/type-builder",
"target": "_blank"
}
},
{
"start": 191,
"end": 218,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/slice-machine#migrate-to-the-type-builder",
"target": "_blank"
}
}
],
"direction": "ltr"
}
]
},
"id": "text_content$eb17366f-8810-464c-aff8-08799dab3039",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading2",
"text": "Change a field's name",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Sometimes you need to change a field's name. For example, a Title field might need a clearer name, like Page Title. To do this, change the field's label but keep its ID. Content is locked to the ID, so changing it means losing the content.",
"spans": [
{
"start": 60,
"end": 65,
"type": "strong"
},
{
"start": 104,
"end": 114,
"type": "strong"
}
],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Here's how to do this with the Prismic CLI. Note that the field's ID (`title`) doesn't change.",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$d0b71963-09e0-4c26-ae7a-9b2b65131aa0",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Change the Title field's label\nnpx prismic field edit title --from-type page --label \"Page Title\"\n\n# Commit changes to Git\ngit add customtypes/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$9d97b6e9-d5eb-4590-be7b-1d3092fecc37",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "No changes are needed in the website's code since the field ID doesn't change.",
"spans": [],
"direction": "ltr"
},
{
"type": "heading2",
"text": "Change a field's type",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Sometimes you need to change a field's type. For example, a plain text field might need to be converted to a rich text field to support formatting. You can't change a field's type in place, since that would lose the field's content.",
"spans": [
{
"start": 60,
"end": 76,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/fields/text",
"target": "_blank"
}
},
{
"start": 109,
"end": 124,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/fields/rich-text",
"target": "_blank"
}
}
],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Instead, add a new field, move the content into it, switch your code to it, then remove the old field. The old field stays in place the whole time, so your live site keeps working.",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$367cac3d-87dc-4237-b514-f50c9dc25da3",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "tip",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"title": [
{
"type": "heading2",
"text": "Best done with AI",
"spans": [],
"direction": "ltr"
}
],
"content": [
{
"type": "paragraph",
"text": "This kind of field change, and every later technique that uses the Migration API, is best done with AI tools like Claude, Codex, and Cursor. Content changes can be complex, and AI tools handle them well.",
"spans": [
{
"start": 67,
"end": 80,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/migration",
"target": "_blank"
}
}
],
"direction": "ltr"
}
],
"hidden_content": []
},
"id": "callout$26391213-a8da-49de-a5a9-5fdcbbb49fa3",
"slice_type": "callout",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "In this example, we'll change a Description field from plain text to rich text that accepts basic formatting.",
"spans": [
{
"start": 32,
"end": 43,
"type": "strong"
}
],
"direction": "ltr"
},
{
"type": "heading3",
"text": "1. Add the new field",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "First, add the new field next to the old one. Give it a new ID, like `description_v2`. The old `description` field stays untouched.",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$75961bd0-4e28-4b72-9150-76baa5cc395e",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Add the new rich text field alongside the old one\nnpx prismic field add rich-text description_v2 --to-type page --label \"Description\" --allow paragraph,strong,em,hyperlink\n\n# Commit changes to Git\ngit add customtypes/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$50c49780-7124-498d-9c64-1bf5250b9ef0",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading3",
"text": "2. Move the content over",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Next, port the existing content into the new field with a migration script. You'll need a Prismic authentication token to use the Migration API. You can create one like this:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$9d1cc968-5cd3-49f9-9aab-bec0ec2f8d36",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "npx prismic token create --write",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$a5750c3f-a326-41df-86db-0212677a0eea",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Save the token in a `.env` file like this:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$8a3d2346-b911-493c-8cd1-b0c02541590b",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "PRISMIC_WRITE_TOKEN=your_write_token",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$69a1c60c-928d-49ee-8c54-b4650f9312ff",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Now write the migration script in a `migrate.js` file:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$d81bc097-ef6b-4052-8d19-58feb06f6202",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "javascript",
"code": [
{
"type": "preformatted",
"text": "// migrate.js\n\nimport { createWriteClient, createMigration, isFilled } from \"@prismicio/client\";\nimport prismicConfig from \"./prismic.config.json\" with { type: \"json\" };\n\n// Load .env into process.env (native, Node 20.12+)\nprocess.loadEnvFile();\n\nconst writeClient = createWriteClient(prismicConfig.repositoryName, {\n writeToken: process.env.PRISMIC_WRITE_TOKEN,\n});\n\nconst migration = createMigration();\n\n// Fetch every page and copy the plain text into the new rich text field\nconst pages = await writeClient.getAllByType(\"page\");\n\nfor (const page of pages) {\n if (!isFilled.keyText(page.data.description)) continue;\n\n page.data.description_v2 = [\n { type: \"paragraph\", text: page.data.description, spans: [] },\n ];\n\n migration.updateDocument(page);\n}\n\nawait writeClient.migrate(migration, {\n reporter: (event) => console.log(event),\n});",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$a89274fa-213d-45f5-985b-7ac61defdb7d",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Run it with Node:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$6fbbb45c-63e7-4f05-a3e6-4504f6e8085e",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "node migrate.js",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$72a3c7b8-e6d5-4f8d-a30a-b38965fea080",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "This adds the content to a Migration Release as drafts. Open the release in your Prismic repository and review the changes. Make sure the new field contains the content you expect. If it looks good, publish the release.",
"spans": [
{
"start": 27,
"end": 44,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/releases",
"target": "_blank"
}
}
],
"direction": "ltr"
},
{
"type": "heading3",
"text": "3. Switch your code to the new field",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Your pages now have both fields. Update your code to read the new one. Here we swap `description` for `description_v2` and render it with the `<PrismicRichText>` component:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$3c608d17-44b8-4a84-9a93-6d31dc6dc505",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "diff",
"code": [
{
"type": "preformatted",
"text": "+ import { PrismicRichText } from \"@prismicio/react\";\n\n- <p>{page.data.description}</p>\n+ <PrismicRichText field={page.data.description_v2} />",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$070f07f4-e54b-4cba-99ea-e22088483310",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Merge your code changes into production.",
"spans": [],
"direction": "ltr"
},
{
"type": "heading3",
"text": "4. Remove the old field",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Finally, once nothing uses the old field, remove it with the Prismic CLI:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$b03a325c-e5ea-4ac0-a978-efb37262f768",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Remove the old plain text field\nnpx prismic field remove description --from-type page\n\n# Commit changes to Git\ngit add customtypes/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$6e08cbaa-fb71-440d-8679-122afa32335f",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading2",
"text": "Split a field into two",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Sometimes you need to split one field into two. For example, a single Name field might need to become separate First Name and Last Name fields so each can be used on its own.",
"spans": [
{
"start": 70,
"end": 74,
"type": "strong"
},
{
"start": 111,
"end": 121,
"type": "strong"
},
{
"start": 126,
"end": 135,
"type": "strong"
}
],
"direction": "ltr"
},
{
"type": "heading3",
"text": "1. Add the new fields",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Add two text fields next to the old one:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$9677e238-2577-4d73-99f4-bf29274e1ed1",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Add the two new text fields alongside the old one\nnpx prismic field add text first_name --to-type page\nnpx prismic field add text last_name --to-type page\n\n# Commit changes to Git\ngit add customtypes/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$fedf1d55-3012-4978-b636-92cf39860068",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading3",
"text": "2. Move the content over",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Split each page's name into the two new fields. You'll need a Prismic authentication token to use the Migration API. You can create one like this:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$2f4307af-f3e3-4d35-8d2c-97307280f3c6",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "npx prismic token create --write",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$96e305fb-0a27-4e55-8c95-dd5ec3ef7f1e",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Save the token in a `.env` file like this:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$4985484e-48df-479f-9541-9c0950c4131a",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "PRISMIC_WRITE_TOKEN=your_write_token",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$559be5a7-c0a1-496c-add6-39a1455ebc22",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Now write the migration script in a `migrate.js` file:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$feb40d68-7642-4652-8c17-ddc98aed358e",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "javascript",
"code": [
{
"type": "preformatted",
"text": "// migrate.js\n\nimport { createWriteClient, createMigration, isFilled } from \"@prismicio/client\";\nimport prismicConfig from \"./prismic.config.json\" with { type: \"json\" };\n\n// Load .env into process.env (native, Node 20.12+)\nprocess.loadEnvFile();\n\nconst writeClient = createWriteClient(prismicConfig.repositoryName, {\n writeToken: process.env.PRISMIC_WRITE_TOKEN,\n});\n\nconst migration = createMigration();\n\n// Fetch every page and split the name into the two new fields\nconst pages = await writeClient.getAllByType(\"page\");\n\nfor (const page of pages) {\n if (!isFilled.keyText(page.data.name)) continue;\n\n const [firstName, ...lastName] = page.data.name.split(\" \");\n page.data.first_name = firstName;\n page.data.last_name = lastName.join(\" \");\n\n migration.updateDocument(page);\n}\n\nawait writeClient.migrate(migration, {\n reporter: (event) => console.log(event),\n});",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$e4a4ecba-a137-4a76-be40-313102c58e00",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Run it with Node:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$9bb58cac-21ba-462c-b4c9-71620a9c23c4",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "node migrate.js",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$d3f98db1-8bf4-4798-a08b-388cfa298196",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Then review and publish the Migration Release in Prismic.",
"spans": [],
"direction": "ltr"
},
{
"type": "heading3",
"text": "3. Switch your code",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Read the two new fields instead of the old one:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$7fca76a3-4d56-4778-81d4-19f7026cc949",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "diff",
"code": [
{
"type": "preformatted",
"text": "- <p>{page.data.name}</p>\n+ <p>{page.data.first_name} {page.data.last_name}</p>",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$4917529f-237f-48ea-998e-1d70ad58a2ad",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Merge your code changes into production.",
"spans": [],
"direction": "ltr"
},
{
"type": "heading3",
"text": "4. Remove the old field",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Once nothing uses it, remove the old field:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$e0521746-40ba-4291-babe-9e4864247e41",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Remove the old field\nnpx prismic field remove name --from-type page\n\n# Commit changes to Git\ngit add customtypes/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$1b90fa2f-4b7a-4277-9f79-982d0d5b9c77",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading2",
"text": "Make a single field repeatable",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Sometimes you need to make a single field repeatable. For example, a blog post might link to one Author through a content relationship and later need to credit several authors. Most fields can't be repeated on their own, so add a repeatable group that holds the field, move the content into it, switch your code, then remove the old field.",
"spans": [
{
"start": 97,
"end": 103,
"type": "strong"
},
{
"start": 114,
"end": 134,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/fields/content-relationship",
"target": "_blank"
}
},
{
"start": 230,
"end": 246,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/fields/repeatable-group",
"target": "_blank"
}
}
],
"direction": "ltr"
},
{
"type": "heading3",
"text": "1. Add the repeatable group",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Add a group field, then add the content relationship inside it. The old `author` field stays untouched.",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$8f29355b-313e-4768-a831-793b6f2698f1",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Add the repeatable group and its content relationship\nnpx prismic field add group authors --to-type blog_post\nnpx prismic field add content-relationship authors.author --to-type blog_post --custom-type author --field name\n\n# Commit changes to Git\ngit add customtypes/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$d181667e-6ff5-4528-a3fd-1abe7ba88637",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading3",
"text": "2. Move the content over",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Move each blog post's author into the group. You'll need a Prismic authentication token to use the Migration API. You can create one like this:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$e71bb48e-3bbf-470e-b32e-c174ce9ea280",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "npx prismic token create --write",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$10af328e-2bcf-48bb-9d9c-1b607d58b24c",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Save the token in a `.env` file like this:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$d4b93c93-0589-419c-974f-7f8e6db9c73e",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "PRISMIC_WRITE_TOKEN=your_write_token",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$2d659074-fe95-4457-babc-00e7f50c6d71",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Now write the migration script in a `migrate.js` file:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$84976da7-2664-4ba8-b6fc-25fd563530ec",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "javascript",
"code": [
{
"type": "preformatted",
"text": "// migrate.js\n\nimport { createWriteClient, createMigration, isFilled } from \"@prismicio/client\";\nimport prismicConfig from \"./prismic.config.json\" with { type: \"json\" };\n\n// Load .env into process.env (native, Node 20.12+)\nprocess.loadEnvFile();\n\nconst writeClient = createWriteClient(prismicConfig.repositoryName, {\n writeToken: process.env.PRISMIC_WRITE_TOKEN,\n});\n\nconst migration = createMigration();\n\n// Fetch every blog post and copy the author relationship into the new group field\nconst posts = await writeClient.getAllByType(\"blog_post\");\n\nfor (const post of posts) {\n if (!isFilled.contentRelationship(post.data.author)) continue;\n\n post.data.authors = [{ author: post.data.author }];\n\n migration.updateDocument(post);\n}\n\nawait writeClient.migrate(migration, {\n reporter: (event) => console.log(event),\n});",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$660f817c-22d1-4f0a-b7b0-d7b2a0026075",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Run it with Node:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$36a3c788-43ec-4772-a45f-8289ab43333f",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "node migrate.js",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$66993025-b2b2-4be0-97ae-5e03d027d3ea",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Then review and publish the Migration Release in Prismic.",
"spans": [],
"direction": "ltr"
},
{
"type": "heading3",
"text": "3. Switch your code",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Map over the group instead of reading the single field:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$90ea9047-d995-4fd5-bd67-49d96da508a1",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "diff",
"code": [
{
"type": "preformatted",
"text": "- {isFilled.contentRelationship(post.data.author) && (\n- <span>{post.data.author.data.name}</span>\n- )}\n+ {post.data.authors.map((item) =>\n+ isFilled.contentRelationship(item.author) ? (\n+ <span key={item.author.id}>{item.author.data.name}</span>\n+ ) : null,\n+ )}",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$20579f41-2bfe-40e6-a861-0773c1d2b481",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Merge your code changes into production.",
"spans": [],
"direction": "ltr"
},
{
"type": "heading3",
"text": "4. Remove the old field",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Once nothing uses it, remove the old field:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$8ca1e34d-03f7-417f-864e-01896fb9d87e",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Remove the old field\nnpx prismic field remove author --from-type blog_post\n\n# Commit changes to Git\ngit add customtypes/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$2454e502-dd9d-4a21-b136-1bf9f39441ec",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Plain links are the exception. A plain link field can be made repeatable in place without losing content, but a content relationship like the `author` field above can't. Prismic keeps the existing value and serves it as a list with one item, so you can skip the steps above. Edit the field:",
"spans": [
{
"start": 33,
"end": 49,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/fields/link",
"target": "_blank"
}
}
],
"direction": "ltr"
}
]
},
"id": "text_content$68f4a909-f4dc-4058-83e8-93be9f8de5fd",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Make the link field repeatable\nnpx prismic field edit cta --from-type page --repeatable\n\n# Commit changes to Git\ngit add customtypes/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$880f9d34-5014-4a5d-ba08-f7aa131cf094",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Then update your code to map over the list:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$21a3c324-74c5-4b18-8ee9-a4520e38a3c6",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "diff",
"code": [
{
"type": "preformatted",
"text": "- <PrismicNextLink field={page.data.cta} />\n+ {page.data.cta.map((link) => (\n+ <PrismicNextLink key={link.key} field={link} />\n+ ))}",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$89462b83-5def-4f61-922c-76167ae4888e",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading2",
"text": "Change the design of a slice",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Sometimes you need to redesign a slice variation that already has content. For example, a `call_to_action` slice's `withButton` variation might need different fields for a new layout. Changing the variation in place would break every published page that uses it, so add a new variation alongside it, like `withButtonV2`.",
"spans": [
{
"start": 33,
"end": 38,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/slices",
"target": "_blank"
}
}
],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "There's no migration script this time. Keep the old variation in place and let content writers move pages to the new variation as they go, starting with the most important ones. Moving every page at once risks breaking layouts no one has reviewed, and most pages may not need the new design. Porting the important pages by hand keeps the risk low and the work small.",
"spans": [],
"direction": "ltr"
},
{
"type": "heading3",
"text": "1. Add the new variation",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Add the new variation to the slice, then model its new fields. The old `withButton` variation stays untouched.",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$d31d5095-e236-4e94-a04c-6387ba867a44",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Add the new variation alongside the old one\nnpx prismic slice add-variation \"With Button V2\" --to call_to_action\n\n# Commit changes to Git\ngit add src/slices/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$902ed086-3c6d-4f14-ba91-3877d45e3190",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading3",
"text": "2. Build the new design",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Render the new variation in your slice component:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$61e3553e-d6e3-4e41-814c-93db04b4871e",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "diff",
"code": [
{
"type": "preformatted",
"text": " // Inside your CallToAction slice component\n+ if (slice.variation === \"withButtonV2\") {\n+ return <CallToActionV2 slice={slice} />\n+ }",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$886cc9f1-a8fb-44d2-baac-8f0a05f69801",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Merge your code changes into production.",
"spans": [],
"direction": "ltr"
},
{
"type": "heading3",
"text": "3. Steer content writers to the new variation",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Relabel the old variation so content writers reach for the new one:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$e68f92ff-e384-4d96-99bf-a1816509d139",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Mark the old variation as legacy\nnpx prismic slice edit-variation withButton --from-slice call_to_action --name \"With Button (legacy)\"\n\n# Commit changes to Git\ngit add src/slices/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": true,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$d155dd45-2be9-4cf8-abf9-ea34c5837544",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "paragraph",
"text": "Content writers can now switch important pages to the new variation when they edit them. Pages that still use the old variation keep working.",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "Once no page uses the old variation, you can remove it:",
"spans": [],
"direction": "ltr"
}
]
},
"id": "text_content$63edef42-6f86-454f-b519-27ab1e46264c",
"slice_type": "text_content",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [
{
"name": null,
"language": "shell",
"code": [
{
"type": "preformatted",
"text": "# Remove the old variation once nothing uses it\nnpx prismic slice remove-variation withButton --from call_to_action\n\n# Commit changes to Git\ngit add src/slices/* prismicio-types.d.ts\n\n# Push changes to Prismic\nnpx prismic push",
"spans": [],
"direction": "ltr"
}
],
"wrap_code": false,
"category": "body_code"
}
],
"primary": {},
"id": "code_snippet$0fd8cda5-df8a-4c6b-b440-6a8fa150eb6d",
"slice_type": "code_snippet",
"slice_label": null
},
{
"variation": "default",
"version": "sktwi1xtmkfgx8626",
"items": [],
"primary": {
"content": [
{
"type": "heading2",
"text": "Wrap-up",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "The techniques in this guide share a few guidelines:",
"spans": [],
"direction": "ltr"
},
{
"type": "list-item",
"text": "Add new fields freely; they don't affect existing content.",
"spans": [],
"direction": "ltr"
},
{
"type": "list-item",
"text": "Use the Migration API to move content into the new fields.",
"spans": [],
"direction": "ltr"
},
{
"type": "list-item",
"text": "Remove old fields only after migrating the content and updating your code.",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "These guidelines apply to any model change, not just the ones in this guide. Whatever you're changing, your published content stays intact and your website stays online.",
"spans": [],
"direction": "ltr"
},
{
"type": "paragraph",
"text": "To learn more about the tools used in this guide, see the Prismic documentation:",
"spans": [],
"direction": "ltr"
},
{
"type": "list-item",
"text": "Prismic CLI: The commands used to model and push your changes.",
"spans": [
{
"start": 0,
"end": 11,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/cli",
"target": "_blank"
}
}
],
"direction": "ltr"
},
{
"type": "list-item",
"text": "Migrate to Prismic: How to write and run a migration script with the Migration API.",
"spans": [
{
"start": 0,
"end": 18,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/migration",
"target": "_blank"
}
}
],
"direction": "ltr"
},
{
"type": "list-item",
"text": "Content modeling: How model changes, including removals, affect published content.",
"spans": [
{
"start": 0,
"end": 16,
"type": "hyperlink",
"data": {
"link_type": "Web",
"url": "https://prismic.io/docs/content-modeling#impact-of-pushing-changes",
"target": "_blank"
}
}
],
"direction": "ltr"
}
]
},
"id": "text_content$25a1dd04-2b81-435e-8ff1-b5ca4dc40f6b",
"slice_type": "text_content",
"slice_label": null
}
],
"meta_title": "Changing Content Models on a Live Prismic Site",
"meta_description": "A practical guide to safely renaming, retyping, splitting, and repeating Prismic content model fields and slices on a live site without losing published content.",
"social_image": {},
"short_name": null,
"part_of_guide": {
"link_type": "Document"
}
}