Synchronize contentful environments via Contentful CLI
Labs & Tutorials
Wed, 05 Aug 2020
- Export master and feature environment content model:
contentful space export --environment-id <branch> --space-id ndwvgngbqj68
- Compare them and find differences:
- Create folder .src/migrations in your project:
- Add Contentful Migration DSL script for each change, a couple of examples:
4.1. Rename field:
module.exports = function (migration) {
const service = migration.editContentType('services');
service.editField('serviceDescriptionRichText')
.name('serviceDescriptionRichText');
}
4.2. Create new field in content type (object approach):
module.exports = function (migration) {
const policy = migration.editContentType('policies')
policy.createField('richTextPolicyDescription',
{
"name": "richTextPolicyDescription",
"type": "RichText",
"localized": false,
"required": false,
"validations": [
],
"disabled": false,
"omitted": false
})
}
5- Execute script:
contentful space migration --environment-id 'master' .\03-add-policy-richtext-field.js --space-id ndvgngbqj68