Error running generated migration
See original GitHub issueDescribe the bug
I use the CLI command to generate a migration (npx mikro-orm migration:create
), and when I try to run the migration (npx mikro-orm migration:up
) I get: TypeError: Class constructor Migration cannot be invoked without ‘new’
Stack trace
[Nest] 65039 - 01/09/2020, 6:16:32 PM [MikroORM] == Migration20200109161524: migrating =======
mikro-orm migration:up
Migrate up to the latest version
Options:
-t, --to Migrate up to specific version [string]
-f, --from Start migration from specific version [string]
-o, --only Migrate only specified versions [string]
-v, --version Show version number [boolean]
-h, --help Show help [boolean]
TypeError: Class constructor Migration cannot be invoked without 'new'
at new Migration20200109161524 (/Users/.../app/backend/src/migrations/Migration20200109161524.ts:56:42)
at Migrator.resolve (/Users/.../app/node_modules/mikro-orm/dist/migrations/Migrator.js:67:26)
at Object.customResolver (/Users/.../app/node_modules/mikro-orm/dist/migrations/Migrator.js:26:46)
at Migration.migration (/Users/.../app/node_modules/umzug/lib/migration.js:63:38)
at /Users/.../app/node_modules/umzug/lib/migration.js:123:37
at Generator.next (<anonymous>)
at step (/Users/.../app/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /Users/.../app/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
at new Promise (<anonymous>)
at new F (/Users/.../app/node_modules/babel-runtime/node_modules/core-js/library/modules/_export.js:36:28)
at /Users/.../app/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12
at Migration._exec (/Users/.../app/node_modules/umzug/lib/migration.js:136:7)
at Migration.up (/Users/.../app/node_modules/umzug/lib/migration.js:90:17)
at Umzug.<anonymous> (/Users/.../app/node_modules/umzug/lib/index.js:152:22)
at PassThroughHandlerContext.finallyHandler (/Users/.../app/node_modules/bluebird/js/release/finally.js:57:23)
at PassThroughHandlerContext.tryCatcher (/Users/.../app/node_modules/bluebird/js/release/util.js:16:23)
To Reproduce Steps to reproduce the behavior:
- npx mikro-orm migration:create
- npx mikro-orm migration:up
Expected behavior Run the migration
Additional context
npx mikro-orm schema:create --run
works without issues, which makes me believe that the configuration is OK, regardless of the complex project structure- mikro-orm is used with NestJS using nestjs-mikro-orm, as used in the sample project
- SQL code for the migration is OK
- Replacing SQL code with “SELECT 1+1” results to the same issue
Versions
Dependency | Version |
---|---|
node | 12.13.1 |
typescript | 3.7.4 |
mikro-orm | 3.0.0-rc.5 |
pg | 7.17.0 |
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Error when running migrations generated by the ...
Describe the bug. When running migrations with mix ecto.migrate the following error occurs: ; To Reproduce A minimal set of resource definitions ......
Read more >Unable to generate an explicit migration in entity framework
This error means there are pending migrations need to be commited before you can execute another explicit migration. You can choose to.
Read more >Error while Add-Migration "Initialize" in .NET 6 Entity ...
While running Add-Migration needs to select the proper library containing dbcontext class for entity framework. 175769-ef-error.jpg.
Read more >Create Migration Error - Questions
Hi! We are trying to use sql server as a n8n database for poc. I added necessary configurations for sql server.
Read more >Troubleshooting migration tasks in AWS Database Migration ...
The most common reason for a migration task running slowly is that there are inadequate resources allocated to the AWS DMS replication instance....
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
So, this might be useful to someone who comes across this. The short answer for me that resolved this issue was setting target property of my tsconfig.json file, to “ESNEXT”
In next RC version you should be able to provide the path to tsconfig via
tsConfigPath
in yourpackage.json
.