Was this article helpful?
Thanks for your feedback
The branches feature in Contentstack allows you to create multiple copies of your stack. You can add numerous branches of your stack and migrate your content to these branches.
Branches primarily help you sync between your code and content model without making significant changes to the code.
Additional Resource: See our detailed documentation on Branches in Contentstack and understand how branches are helpful in real-world scenarios.
Using the Contentstack CLI's Migration plugin, you can migrate your content from one branch to another using a migration script.
Additional Resource: We recommend you to refer to our extensive guide on migration plugin and how to write a migration script for your content or refer our GitHub page.
In this guide, let's look at different possible use case scenarios where you can use the CLI migration plugin to migrate your content from one branch to another.
Here are a few possible scenarios where you can use the migration plugin to migrate your content.
Let's understand each use case in detail.
Note: We assume you are well versed with the migration script and migration plugin. If not, read our detailed documentation on how to get started with the migration script and use the migration plugin to migrate your content.
Consider a scenario where you want to apply a minor change to your content type. In this example, let's understand how to rename/ remove a field in your content type using branches.
To do this, follow the steps given below:
Warning: We recommend you to keep the existing fields and optionally delete the old fields after your latest changes are published live. This will help you easily roll-back, in case the new changes are not as expected.
Additional Resource: We recommend you check some example scripts on our GitHub page. This will help you get started with the tasks mentioned above.
csdx cm:migration -A -n <file_path> -k <api_key> -b <branch_name>
Note: Make sure, while running the script, it should point to the target branch.
While deploying, remember to deploy the migration script first and then deploy the UI.
This is a complex use case where you want to make some significant changes to your stack. While revamping your website's content models or restructuring your application, you have to include some major updates to your stack.
Consider an example where you want to update the content models of your stack. Let's see the steps involved in executing this example using branches:
Additional Resource: We recommend you check some example scripts on our GitHub page. This will help you get started with the tasks mentioned above.
csdx cm:migration -A -n <file_path> -k <api_key> -b <branch_name>
Note: Make sure, while running the script, it should point to the target branch.
Additional Resource: Read our detailed guide on how to use aliases in content branching.
Note: By using an alias for release, you can eliminate the risk of data loss. In case of any errors, it will by default rollback to the old code/ branch.
Note: We recommend you to use this method only if your changes are minimal and can be easily merged with the main branch.
Additional Resource: We highly recommend you to check our GitHub page for more information on migration script creation, use cases, and advanced examples.
Was this article helpful?
Thanks for your feedback