Synchronize contentful environments via Contentful CLI

Labs & Tutorials

Wed, 05 Aug 2020

  1. Export master and feature environment content model:
contentful space export --environment-id <branch> --space-id ndwvgngbqj68
  1. Compare them and find differences:

  1. Create folder .src/migrations in your project:
  2. 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');

4.2. Create new field in content type (object approach):

module.exports = function (migration) {
    const policy = migration.editContentType('policies')
            "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
  1. Validate migration:

  2. New changes from contentful feature environment applied in master:


written by Senior Orc Developer