Skip to content

bug: mikro-orm migration:list doesn't work with mongodb driver (Cannot read properties of undefined (reading 'toISOString')) #4698

@ruscon

Description

@ruscon

Describe the bug
The cli package uses executed_at property from the migration table
https://github.com/mikro-orm/mikro-orm/blob/v5.8.1/packages/cli/src/commands/MigrationCommandFactory.ts#L150

The migrations package creates the executed_at property in the migration table
https://github.com/mikro-orm/mikro-orm/blob/v5.8.1/packages/migrations/src/MigrationStorage.ts#L76

But the migrations-mongodb package creates the created_at property in the migration table
https://github.com/mikro-orm/mikro-orm/blame/v5.8.1/packages/migrations-mongodb/src/MigrationStorage.ts#L22

Stack trace

mikro-orm migration:list
List all executed migrations
Options:
  -v, --version  Show version number                                   [boolean]
  -h, --help     Show help                                             [boolean]
TypeError: Cannot read properties of undefined (reading 'toISOString')
    at /Users/user/projects/company/service/node_modules/@mikro-orm/cli/commands/MigrationCommandFactory.js:126:90
    at Array.map (<anonymous>)
    at Function.handleListCommand (/Users/user/projects/company/service/node_modules/@mikro-orm/cli/commands/MigrationCommandFactory.js:126:28)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Function.handleMigrationCommand (/Users/user/projects/company/service/node_modules/@mikro-orm/cli/commands/MigrationCommandFactory.js:83:17)
Warning: run-commands command "npx mikro-orm migration:list" exited with non-zero status code

To Reproduce
Steps to reproduce the behavior:

  1. Use mongo driver
  2. run npx mikro-orm migration:list

Expected behavior
No errors

Additional context

Versions

➜ npx mikro-orm debug
Current MikroORM CLI configuration
 - dependencies:
   - mikro-orm 5.8.1
   - node 18.13.0
   - mongodb 5.8.1
   - typescript 4.9.5
 - package.json found
 - ts-node enabled
 - searched config paths:
   - /Users/user/projects/company/service/apps/api/src/nestjs/data-sources/mongo.ts (found)
   - /Users/user/projects/company/service/dist/apps/api/src/nestjs/data-sources/mongo.js (found)
   - /Users/user/projects/company/service/apps/api/src/mikro-orm.config.ts (not found)
   - /Users/user/projects/company/service/apps/api/mikro-orm.config.ts (not found)
   - /Users/user/projects/company/service/apps/api/src/mikro-orm.config.js (not found)
   - /Users/user/projects/company/service/apps/api/mikro-orm.config.js (not found)
 - configuration found
 - database connection succesful
 - will use `entities` array (contains 4 references and 0 paths)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions