JvM Contentful Migrations
Getting started
Install
npm i @jungvonmatt/contentful-migrations
Commands
help
npx migrations help [command]
init
npx migrations init
Initializes migrations and stores the config values in the package.json
or the .migrationsrc
file.
Configuration values
accessToken | undefined | Contentful Management Token. Just run npx contentful login and you're done. |
spaceId | undefined | Contentful Space id |
defaultEnvironment | 'master' | Contentful Space environment. Acts as default if there is no environment named after the current git branch or the passed env doesn't exist |
contentTypeId | 'config' | Id of a content model holding global config values (Required for storing the migration version) |
fieldId | 'migration' | Id of the field where the migration version is stored |
directory | './migrations' | Directory where the migration files are stored |
generate
Generate an empty migration script.
This command will also add an initial migration to add the contentType and the field if they not already exist.
npx migrations generate
fetch
Generate a migration script based on passed content-type.
This command will also add an initial migration to add the contentType and the field if they not already exist.
npx migrations fetch -c <my-content-type>
migrate
Runs all "new" migrations on the current environment or the environment specified by the -e
param
npx migrations migrate
content
Transfer content from one contentful environment to another.
This command will not overwrite existing content unless you say so.
npx migrations content --source-env <environment> --dest-env <environment>
Optional Arguments
--content-type
: Limit to specific content-type and it's dependencies.
--diff
: Manually choose skip/overwrite for every conflicting content.
--force
: No manual diffing. Overwrites all conflicting entries/assets.
--verbose
: Show tree of entries/assets which should be migrated.

doc
Generate simple markdown docs for the content-types
npx migrations doc -e <environment> -p <path/to/docs>
Optional Arguments
--template
: Use a custom template for docs. .js
with default export or .mustache
is allowed
--extension
: Use a custom file extension (default is .md
)
Can I contribute?
Of course. We appreciate all of our contributors and
welcome contributions to improve the project further. If you're uncertain whether an addition should be made, feel
free to open up an issue and we can discuss it.