mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
fix: release query runner when there is no migration to revert (#11232)
Co-authored-by: Adrien PEREZ <adrien-perez@samse.fr>
This commit is contained in:
parent
2d8c5158db
commit
a46eb0a7e1
@ -417,6 +417,8 @@ export class MigrationExecutor {
|
||||
this.connection.logger.logSchemaBuild(
|
||||
`No migrations were found in the database. Nothing to revert!`,
|
||||
)
|
||||
// if query runner was created by us then release it
|
||||
if (!this.queryRunner) await queryRunner.release()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
30
test/github-issues/11231/issue-11231.ts
Normal file
30
test/github-issues/11231/issue-11231.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { expect } from "chai"
|
||||
import "reflect-metadata"
|
||||
import { DataSource } from "../../../src/data-source/DataSource"
|
||||
import {
|
||||
closeTestingConnections,
|
||||
createTestingConnections,
|
||||
} from "../../utils/test-utils"
|
||||
|
||||
describe("github issues > #11231 Error trying to revert last migration when there is none on Oracle", () => {
|
||||
let dataSources: DataSource[]
|
||||
before(
|
||||
async () =>
|
||||
(dataSources = await createTestingConnections({
|
||||
entities: [],
|
||||
enabledDrivers: ["oracle"],
|
||||
migrations: [],
|
||||
schemaCreate: false,
|
||||
dropSchema: true,
|
||||
})),
|
||||
)
|
||||
after(() => closeTestingConnections(dataSources))
|
||||
|
||||
it("should not throw when migrations list is empty", () =>
|
||||
Promise.all(
|
||||
dataSources.map(async (dataSource) => {
|
||||
await dataSource.undoLastMigration()
|
||||
expect(await dataSource.destroy()).to.not.throw
|
||||
}),
|
||||
))
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user