Entry Migration
In Branches, the merge operation is performed on content types and not on the entries within the content types. With the Entry Migration utility, created as part of the Entry Migration flow, you can now merge the entries along with the content types.
This step-by-step guide lets you use the Entry Migration utility to perform the merge operation on entries.
Prerequisites
- Contentstack account
- CLI installed and configured (version 1.7.0 and above)
- CLI authenticated
- Branches enabled for your organization
- Merge operation performed
Usage
csdx cm:stacks:migration --multiple --file-path <value> --config compare-branch:<value> --branch <value> --stack-api-key <value>
Options
- -k, --stack-api-key=stack-api-key: Stack API key.
- --branch=branch: Base branch.
- --config=config: Inline configuration, compare-branch:<value>. The key for receiving the compare branch name.
- --file-path=filepath: Path where the entry migration files are stored.
- --multiple: Migrate multiple content files in a single instance. You must mention the folder path where your migration script files are stored.
Example
csdx cm:stacks:migration --multiple --file-path ./merge_scripts/merge_scripts_bf7xxx-xxx-xxx-xxx-xxx_xxx044 --config compare-branch:develop --branch main --stack-api-key bltxxxxxxxxxxxe
Steps for execution
After performing the merge operation, the merge command generates the merge scripts, and you will get the following message in your terminal:
Follow the steps below to run the migration command:
- Copy the entry migration command from the message displayed in your terminal.
- Run the command in your terminal.
csdx cm:stacks:migration --multiple --file-path <value> --config compare-branch:<value> --branch <value> --stack-api-key <value>
This runs the merge scripts, which will be used to merge the entries.
You can also customize the generated merge script to suit your requirements.
For example, if you want to publish the entries using the merge scripts, you can add the publish entry task as follows:
const publishEntriesTask = contentTypeUID => {
return {
title: `Publish entries for Content type '${contentTypeUID}'`,
successMessage: `Entries published successfully for '${contentTypeUID}'`,
failedMessage: `Failed to publish entries for '${contentTypeUID}'`,
task: async params => {
try {
// Add your custom logic here
} catch (error) {
console.log(error)
}
},
}
}