runMigration doesn't support typescript files as input
See original GitHub issueExpected Behavior
Something like the following should execute.
const config: RunMigrationConfig = {
filePath: 'someFilePath.ts',
spaceId,
environmentId,
accessToken,
};
await runMigration(config);
Actual Behavior
The contentful-schema/1/00-languages.ts script could not be parsed, as it seems to contain syntax errors.
contentful-schema/1/00-languages.ts:1
import { MigrationFunction } from 'contentful-migration';
^^^^^^
Context
Trying to run multiple migration files in sequence based on various rules. It makes sense to use runMigration rather running command line calls from within a ts script.
Environment
Node Version: 12.19.0 “contentful-migration”: “^4.0.6”,
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Documentation - Migrating from JavaScript - TypeScript
During our JS to TS migration, we'll need to separate our input files to prevent TypeScript from overwriting them.
Read more >TypeORM Migration: File must contain a TypeScript ...
I was just using npx typeorm migration:show -d ./src/data-source.ts and getting the same error as above ( File must contain a TypeScript ......
Read more >How to migrate DBs with NodeJS and TypeScript - Medium
Migration of a database is a process of applying changes to the database. For example, in SQL it'd be creating/dropping/altering of tables, ...
Read more >A simple guide for migrating from JavaScript to TypeScript
In that file, simply write declare module "my-module" (with the “my-module” being the package that doesn't have Typescript). Then, in your ...
Read more >Incremental Migration from JavaScript to TypeScript in Our ...
And secondly, creating declaration files was also excellent for understanding the codebase better, if you were not already fully familiar with ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@phawxby I’m just running everything through
ts-node
, no compilation required and it loads typescript files without issue.e.g.
ts-node migration.ts
where migration.ts is:edit: updated the example to contain an absolute file path, as is required by
runMigration
, so people know about it.For anyone getting a
TypeError: migrationCreator is not a function
error, make sure you usemodule.exports
instead ofexport default
. This is what your migration file would look like: