Registry / devops / mi-contentful-migrate

mi-contentful-migrate

JSON →
library0.18.23jsnpmunverified

Migration tooling for Contentful that manages schema changes as incremental scripted migrations using the contentful-migration syntax. Version 0.18.23 (stable, not actively maintained) enables state tracking per content type via a dedicated Migration content type in Contentful. Unlike one-off scripts, it keeps a history of migrations in a version-control-friendly folder structure and supports up/down migrations. The repository is archived and no longer maintained; users may need to fork or seek alternatives. Requires Node >=18 and a Contentful Management API token.

npm install mi-contentful-migrate
INSTALL
IMPORT
SIG · MI-CONTENTFUL-MIGR
M
mi-contentful-migrate
devopsjavascriptv0.18.23
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

module.exports.description
module.exports.description = 'Migration description';
export const description = '...'; //ESM syntax not supported; module.exports is required for migration files
Migrations are CommonJS modules. ESM is not supported.
module.exports.up
module.exports.up = function(migration) { ... };
export default function up(migration) { ... } //ESM will not be recognized
The migration function receives a Migration object from contentful-migration.
module.exports.down
module.exports.down = function(migration) { ... };
Missing down for irreversible migrations (optional but recommended).
Down migration should revert the up changes. Can be omitted if irreversible.

Shows initializing the tool, creating a migration file, and running migrations.

// Initialize migrations directory npx ctf-migrate init --access-token $CONTENTFUL_MANAGEMENT_ACCESS_TOKEN --space-id $CONTENTFUL_SPACE_ID --environment-id master // Create a migration file: migrations/post/1513743198536-create-post.js module.exports.description = 'Create Post content type'; module.exports.up = migration => { const post = migration.createContentType('post').name('Post').displayField('title').description('Post model'); post.createField('title').name('Title').type('Symbol').required(true); }; module.exports.down = migration => { migration.deleteContentType('post'); }; // Run pending migrations npx ctf-migrate up --access-token $CONTENTFUL_MANAGEMENT_ACCESS_TOKEN --space-id $CONTENTFUL_SPACE_ID --environment-id master
Debug
Known issues
deprecatedRepository is archived and no longer maintained.
fix
Consider forking the repository or switching to alternatives like @deluan/contentful-migrate or contentful-migration directly.
affects: >=0.0.0
gotchaMigrations directory must be inside the project root (or a subdirectory) to avoid out-of-sync schema.
fix
Set CONTENTFUL_MIGRATIONS_DIR to a path within the project, e.g., ./migrations.
affects: >=0.0.0
breakingNode.js >=18 required; older versions are unsupported and may cause errors.
fix
Upgrade Node.js to version 18 or later.
affects: >=0.18.0
gotchaEnvironment variables CONTENTFUL_SPACE_ID and CONTENTFUL_ENV_ID must be set if not provided via CLI.
fix
Export the variables or pass --space-id and --environment-id options.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'contentful-migration'
contentful-migration is not installed or is a peer dependency missing.
fix
npm install contentful-migration --save-dev
Error: Migration file does not export an up function
Migration file uses ESM export syntax (export default/export function) instead of module.exports.
fix
Use module.exports.up = function(migration) { ... };
Error: Space ID is required
CONTENTFUL_SPACE_ID environment variable not set and --space-id not provided.
fix
Set CONTENTFUL_SPACE_ID environment variable or pass --space-id option.
Upgrade
Version history
0.18.23latest on npm
Audit
Dependencies
contentful-migrationrequiredCore dependency for defining migration steps (create/update/delete content types and fields). The same syntax is used in migration files.
Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources
mi-contentful-migrate — npm install mi-contentful-migrate · libregistry