On this page
For migrations you will need Contentful's command line interface tool.
- Node LTS
brew install contentful-cli
npm install -g contentful-cli
yarn global add contentful-cli
You will need to login to contentful on your computer. Run
contentful login and follow the prompts, see below for an example:
❯ contentful loginA browser window will open where you will log in (or sign up if you don’t have an account), authorize this CLI tool and paste your CMA token here:? Open a browser window now? Yes? Paste your token here: [hidden]Great! Your CMA token is now stored on your system. (Located at /Users/zander/.contentfulrc.json)You can always run contentful logout to remove it.
Create a new CMA token (personal access token) from this page.
Every time you need to modify a content model, a new migration script should be created. It needs to be carefully modeled so that you don't overwrite existing types and content.
For more information on how to model your content programmatically, see these docs
When editing existing fields, it can be useful to view the JSON representation of the content model to see what is there. e.g. app.contentful.com/spac...view
- Migration docs
- Editor interfaces
- Contentful migrations tutorial
- Video overview of using the contentful CLI
- CMS as code - article about migrations etc on the Contentful help centre
- Managing multiple environments
- Example migrations
It is a good idea to create a
test environment that is a clone of
master so that everything can be checked before running the migration script "for real".
contentful space migration --space-id a65gr7u3g09k --environment-id 'test' 01-add-article-cta-type.js