question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"migrationCreator is not a function" when using contentful-migration "runMigration"

See original GitHub issue

Expected Behavior

-The contentful-migration library should work as described in readme file. -The runMigration command should run the multiple migration scripts.

Actual Behavior

`mbpus0477hsra18:<DIR> <USUR_NAME>$ contentful space migration --space-id <SPACE_ID> scripts/contentful-migrations/migration_runner.js 

TypeError: migrationCreator is not a function
    at /Users/<USUR_NAME>/.nvm/versions/node/v9.11.1/lib/node_modules/contentful-cli/node_modules/contentful-migration/built/lib/migration-steps/index.js:139:16
    at tryCatcher (/Users/<USUR_NAME>/.nvm/versions/node/v9.11.1/lib/node_modules/contentful-cli/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/Users/<USUR_NAME>/.nvm/versions/node/v9.11.1/lib/node_modules/contentful-cli/node_modules/bluebird/js/release/method.js:39:29)
    at Object.migration (/Users/<USUR_NAME>/.nvm/versions/node/v9.11.1/lib/node_modules/contentful-cli/node_modules/contentful-migration/built/lib/migration-steps/index.js:138:23)
    at migration (/Users/<USUR_NAME>/.nvm/versions/node/v9.11.1/lib/node_modules/contentful-cli/node_modules/contentful-migration/built/lib/migration-parser.js:43:49)
    at run (/Users/<USUR_NAME>/.nvm/versions/node/v9.11.1/lib/node_modules/contentful-cli/node_modules/contentful-migration/built/bin/cli.js:53:29)
    at exports.migration (/Users/<USUR_NAME>/.nvm/versions/node/v9.11.1/lib/node_modules/contentful-cli/dist/cmds/space_cmds/migration.js:82:28)
    at <anonymous>
`
const runMigration = require('contentful-migration/built/bin/cli').default;
const path = require('path');

const options = {
  spaceId: '<SPACE_ID>',
  accessToken:
    '<TOKEN>',
  yes: true,
};

const migrations = async () => {
  await runMigration({
    ...options,
    ...{
      filePath: path.join(__dirname, '<FILE_PATH>'),
    },
  });

  await runMigration({
    ...options,
    ...{ filePath: path.join(__dirname, '<FILE_PATH>') },
  });

  await runMigration({
    ...options,
    ...{ filePath: path.join(__dirname, '<FILE_PATH>') },
  });

  await runMigration({
    ...options,
    ...{ filePath: path.join(__dirname, '<FILE_PATH>') },
  });
};

migrations();

Steps to Reproduce

  1. Run the script in the console

Context

I am unable to run the migration scripts in order. The error that is provided is not very helpful and seems to be an internal application error.

Environment

  • Node Version: 9.11.1
  • Package Manager Version: 5.6
  • Operating System: MAC OS 10.13.5
  • Package Version: “contentful-migration”: “^0.10.0”,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
zceicommented, Jul 31, 2018

runMigration is not intended to be used with the contentful-cli runner. The CLI actually uses runMigration to do the migration. For that it needs to receive a function (what you export from the migration file).

Your “migration file” is a simple one-off method call. Nothing is exported, so nothing can be run. Agreed, the error message could be a bit nicer.

Out of curiosity: where did you get the impression from, that you could do such thing with the contentful-cli and our migration tooling?

1reaction
axe312gercommented, Jul 25, 2018

Thank you, we will have a look

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: migrationCreator is not a function - Stack Overflow
With this in mind, am I best to store JSON values for the multiple assets I want to upload in a seperate file,...
Read more >
The right way to migrate content the Contentful Migration CLI
With the Contentful Migration CLI, we offer a framework that makes migrations easy and that also makes it possible for developers to script ......
Read more >
Issues with the contentful migration CLI - APIs
I am having issues with the contentful migration cli tool. When I run the tool with the angry-dog.js I get the following: TypeError: ......
Read more >
Contentful Migration Tooling - YouTube
They spend time writing migration scripts and showcase how you can use the command line tooling to programmatically make content model ch …...
Read more >
The contentful-migration from contentful - Coder Social
const { runMigration } = require('contentful-migration') function ... "migrationCreator is not a function" when using contentful-migration "runMigration" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found