Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ruscon opened this issue Sep 14, 2023 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ruscon
Copy link
Contributor

ruscon commented Sep 14, 2023

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)
@ruscon ruscon changed the title bug: mikro-orm migration:list doesn't work with mongodb driver (Cannot read properties of undefined (reading 'toISOString')) bug: mikro-orm migration:list doesn't work with mongodb driver (Cannot read properties of undefined (reading 'toISOString')) Sep 14, 2023
@ruscon ruscon changed the title bug: mikro-orm migration:list doesn't work with mongodb driver (Cannot read properties of undefined (reading 'toISOString')) bug: mikro-orm migration:list doesn't work with mongodb driver (Cannot read properties of undefined (reading 'toISOString')) Sep 14, 2023
@B4nan B4nan added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers labels Sep 14, 2023
@B4nan B4nan closed this as completed in 2d9fc86 Sep 20, 2023
@ruscon
Copy link
Contributor Author

ruscon commented Sep 21, 2023

@B4nan

versions:

    "@mikro-orm/cli": "^5.8.2",
    "@mikro-orm/core": "^5.8.2",
    "@mikro-orm/migrations-mongodb": "^5.8.2",
    "@mikro-orm/mongodb": "^5.8.2",
    "@mikro-orm/nestjs": "^5.2.1",
  1. if there are no executed migrations before - ok
  2. if there are no executed migrations before, only new - ok
  3. if there are old executed migrations (before fix) - error:
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 'length')
    at /Users/user/projects/company/project/node_modules/@mikro-orm/cli/CLIHelper.js:103:60
    at Array.forEach (<anonymous>)
    at /Users/user/projects/company/project/node_modules/@mikro-orm/cli/CLIHelper.js:102:17
    at Array.forEach (<anonymous>)
    at Function.dumpTable (/Users/user/projects/company/project/node_modules/@mikro-orm/cli/CLIHelper.js:101:14)
    at Function.handleListCommand (/Users/user/projects/company/project/node_modules/@mikro-orm/cli/commands/MigrationCommandFactory.js:123:31)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Function.handleMigrationCommand (/Users/user/projects/company/project/node_modules/@mikro-orm/cli/commands/MigrationCommandFactory.js:83:17)

@B4nan
Copy link
Member

B4nan commented Sep 21, 2023

8ae7eeb should help, please try the next dev version, will be out in ~15 minutes

@ruscon
Copy link
Contributor Author

ruscon commented Sep 21, 2023

@B4nan works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants