Skip to content

MigrationExecutor - Query runner already released. #10083

@p1k2i

Description

@p1k2i

Issue description

MigrationExecutor - Query runner already released.

Expected Behavior

getExecutedMigrations() should return array of all executed migrations to indicated dataSource.

Actual Behavior

MigrationExecutor is just throwing QueryRunnerAlreadyReleasedError when you attempt to run getExecutedMigrations().

QueryRunnerAlreadyReleasedError: Query runner already released. Cannot run queries anymore.
at MysqlQueryRunner.query (C:\project\node_modules\typeorm\src\driver\mysql\MysqlQueryRunner.ts:187:36)
at SelectQueryBuilder.loadRawResults (C:\project\node_modules\src\query-builder\SelectQueryBuilder.ts:3789:43)
at SelectQueryBuilder.getRawMany (C:\project\node_modules\src\query-builder\SelectQueryBuilder.ts:1626:40)
at MigrationExecutor.loadExecutedMigrations (C:\project\node_modules\src\migration\MigrationExecutor.ts:563:18)
at C:\project\node_modules\src\migration\MigrationExecutor.ts:106:31
at processTicksAndRejections (node:internal/process/task_queues:95:5)

There is the problem:
After internal await this.createMigrationsTableIfNotExist(queryRunner); the queryRunner is realizing and still used for next operation.
Screenshot_612

Steps to reproduce

const migrationExecutor = new MigrationExecutor(dataSource);

// Get the list of executed migrations
const executedMigrations = await migrationExecutor.getExecutedMigrations();

My Environment

Dependency Version
Node.js version 18.16.0
Typescript version 5.0.4
TypeORM version 0.3.16

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, and I know how to start.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions