Change Master Locale
While importing data using the Contentstack’s CLI, if the destination stack has a different master locale than the source stack, the API throws an error indicating that the master locale of the incoming data does not exist in the destination stack.
As a solution, you can change the master locale of the data exported from the CLI using the change-master-locale utility so that it matches the master locale of the destination stack.
Prerequisites
- Contentstack account
- CLI installed (version 1.1.0 and above)
Steps for Execution
- Export the data from the source stack using the cm:stacks:export command.
- Download the examples folder and navigate to the folder using the cd command in the terminal.
cd <path-to-examples>
- Find the change-master-locale script in the examples folder. Execute the script using the migration command as follows:
csdx cm:stacks:migration --file-path ./change-master-locale/02-change-master-locale-new-file-structure.js --config target_locale:<target-locale> data_dir:<path-to-the-exported-data>
Note: path-to-the-exported-data can either be the relative path or the absolute path.
Alternatively, You can save the config parameters to a config.json file and use it as follows:
csdx cm:stacks:migration --file-path ./change-master-locale/02-change-master-locale-new-file-structure.js --config-file <path-to-the-config-file>
Note: If you used the CLI version below 1.9.0 to export the data, use the 01-change-master-locale.js script instead of 02-change-master-locale-new-file-structure.js in the examples above.
- Import the data to the target stack using the cm:stacks:import command.
Troubleshoot
If you are facing a Migration Unsuccessful or Module cannot be found error, please try one of the following troubleshooting methods:
- Troubleshoot in your current terminal session:
- Windows (CMD):
FOR /F "usebackq tokens=*" %i IN (`npm root -g @contentstack/cli`) DO SET NODE_PATH=%i/@contentstack/cli/node_modules
- Windows (PowerShell):
foreach ($i in $(npm root -g @contentstack/cli)) { $env:NODE_PATH = "$i/@contentstack/cli/node_modules" }
- Mac/Unix:
export NODE_PATH="$(npm root -g @contentstack/cli)/@contentstack/cli/node_modules"
- Windows (CMD):
Limitations
- This utility does not work for the clone command.