-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: skip duplicated pending migrations Make the behavior the same whether duplicated migrations applied in one step or not. Closes: #4701 * style: revert unnecessary formatting * fix: throw exception when duplicate migrations
- Loading branch information
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import "reflect-metadata"; | ||
import {expect} from "chai"; | ||
import { | ||
createTestingConnections, | ||
closeTestingConnections, | ||
reloadTestingDatabases | ||
} from "../../utils/test-utils"; | ||
import { Connection } from "../../../src/connection/Connection"; | ||
|
||
describe("github issues > #4701 Duplicate migrations are executed.", () => { | ||
let connections: Connection[]; | ||
before(async () => connections = await createTestingConnections({ | ||
migrations: [__dirname + "/migration/*.js"], | ||
enabledDrivers: ["postgres"], | ||
schemaCreate: true, | ||
dropSchema: true | ||
})); | ||
beforeEach(() => reloadTestingDatabases(connections)); | ||
after(() => closeTestingConnections(connections)); | ||
|
||
it("should throw error if there're duplicate migrations", () => Promise.all(connections.map(async connection => { | ||
await expect(connection.runMigrations()).to.be.rejectedWith(Error, "Duplicate migrations: ExampleMigrationOne1567759789051"); | ||
}))); | ||
}); |
7 changes: 7 additions & 0 deletions
7
test/github-issues/4701/migration/1567759789051-ExampleMigration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { MigrationInterface } from "../../../../src/migration/MigrationInterface"; | ||
import { QueryRunner } from "../../../../src/query-runner/QueryRunner"; | ||
|
||
export class ExampleMigrationOne1567759789051 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<any> {} | ||
public async down(queryRunner: QueryRunner): Promise<any> {} | ||
} |
7 changes: 7 additions & 0 deletions
7
test/github-issues/4701/migration/1567759832591-ExampleMigrationTwo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { MigrationInterface } from "../../../../src/migration/MigrationInterface"; | ||
import { QueryRunner } from "../../../../src/query-runner/QueryRunner"; | ||
|
||
export class ExampleMigrationOne1567759789051 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<any> {} | ||
public async down(queryRunner: QueryRunner): Promise<any> {} | ||
} |
7 changes: 7 additions & 0 deletions
7
test/github-issues/4701/migration/1571426391120-ExampleMigrationThree.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { MigrationInterface } from "../../../../src/migration/MigrationInterface"; | ||
import { QueryRunner } from "../../../../src/query-runner/QueryRunner"; | ||
|
||
export class ExampleMigrationThree1571426391120 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<any> {} | ||
public async down(queryRunner: QueryRunner): Promise<any> {} | ||
} |