Skip to content

Commit 76e165d

Browse files
apielAlexandre Piel
andauthored
feat: update cli migration up and down from any to void (#5630)
Co-authored-by: Alexandre Piel <alexandre.piel@zooplus.com>
1 parent 0adbe5c commit 76e165d

File tree

9 files changed

+92
-92
lines changed

9 files changed

+92
-92
lines changed

docs/migrations.md

Lines changed: 70 additions & 70 deletions
Large diffs are not rendered by default.

docs/zh_CN/migrations.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ typeorm migration:create -n PostRefactoring
9494
import { MigrationInterface, QueryRunner } from "typeorm";
9595

9696
export class PostRefactoringTIMESTAMP implements MigrationInterface {
97-
async up(queryRunner: QueryRunner): Promise<any> {}
97+
async up(queryRunner: QueryRunner): Promise<void> {}
9898

99-
async down(queryRunner: QueryRunner): Promise<any> {}
99+
async down(queryRunner: QueryRunner): Promise<void> {}
100100
}
101101
```
102102

@@ -115,11 +115,11 @@ export class PostRefactoringTIMESTAMP implements MigrationInterface {
115115
import { MigrationInterface, QueryRunner } from "typeorm";
116116

117117
export class PostRefactoringTIMESTAMP implements MigrationInterface {
118-
async up(queryRunner: QueryRunner): Promise<any> {
118+
async up(queryRunner: QueryRunner): Promise<void> {
119119
await queryRunner.query(`ALTER TABLE "post" ALTER COLUMN "title" RENAME TO "name"`);
120120
}
121121

122-
async down(queryRunner: QueryRunner): Promise<any> {
122+
async down(queryRunner: QueryRunner): Promise<void> {
123123
await queryRunner.query(`ALTER TABLE "post" ALTER COLUMN "name" RENAME TO "title"`); // 恢复"up"方法所做的事情
124124
}
125125
}
@@ -171,11 +171,11 @@ typeorm migration:generate -n PostRefactoring
171171
import { MigrationInterface, QueryRunner } from "typeorm";
172172

173173
export class PostRefactoringTIMESTAMP implements MigrationInterface {
174-
async up(queryRunner: QueryRunner): Promise<any> {
174+
async up(queryRunner: QueryRunner): Promise<void> {
175175
await queryRunner.query(`ALTER TABLE "post" ALTER COLUMN "title" RENAME TO "name"`);
176176
}
177177

178-
async down(queryRunner: QueryRunner): Promise<any> {
178+
async down(queryRunner: QueryRunner): Promise<void> {
179179
await queryRunner.query(`ALTER TABLE "post" ALTER COLUMN "name" RENAME TO "title"`);
180180
}
181181
}
@@ -194,7 +194,7 @@ export class PostRefactoringTIMESTAMP implements MigrationInterface {
194194
import { MigrationInterface, QueryRunner, Table, TableIndex, TableColumn, TableForeignKey } from "typeorm";
195195

196196
export class QuestionRefactoringTIMESTAMP implements MigrationInterface {
197-
async up(queryRunner: QueryRunner): Promise<any> {
197+
async up(queryRunner: QueryRunner): Promise<void> {
198198
await queryRunner.createTable(
199199
new Table({
200200
name: "question",
@@ -258,7 +258,7 @@ export class QuestionRefactoringTIMESTAMP implements MigrationInterface {
258258
);
259259
}
260260

261-
async down(queryRunner: QueryRunner): Promise<any> {
261+
async down(queryRunner: QueryRunner): Promise<void> {
262262
const table = await queryRunner.getTable("question");
263263
const foreignKey = table.foreignKeys.find(fk => fk.columnNames.indexOf("questionId") !== -1);
264264
await queryRunner.dropForeignKey("question", foreignKey);

src/commands/MigrationCreateCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ export class MigrationCreateCommand implements yargs.CommandModule {
8282
8383
export class ${camelCase(name, true)}${timestamp} implements MigrationInterface {
8484
85-
public async up(queryRunner: QueryRunner): Promise<any> {
85+
public async up(queryRunner: QueryRunner): Promise<void> {
8686
}
8787
88-
public async down(queryRunner: QueryRunner): Promise<any> {
88+
public async down(queryRunner: QueryRunner): Promise<void> {
8989
}
9090
9191
}

test/functional/migrations/show-command/migration/1530542855524-ExampleMigration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { MigrationInterface } from "../../../../../src/migration/MigrationInterf
22
import { QueryRunner } from "../../../../../src/query-runner/QueryRunner";
33

44
export class ExampleMigration1530542855524 implements MigrationInterface {
5-
public async up(queryRunner: QueryRunner): Promise<any> {
5+
public async up(queryRunner: QueryRunner): Promise<void> {
66
}
7-
public async down(queryRunner: QueryRunner): Promise<any> {
7+
public async down(queryRunner: QueryRunner): Promise<void> {
88
}
99
}

test/functional/migrations/show-command/migration/1530542855524-ExampleMigrationTwo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { MigrationInterface } from "../../../../../src/migration/MigrationInterf
22
import { QueryRunner } from "../../../../../src/query-runner/QueryRunner";
33

44
export class ExampleMigrationTwo1530542855524 implements MigrationInterface {
5-
public async up(queryRunner: QueryRunner): Promise<any> {
5+
public async up(queryRunner: QueryRunner): Promise<void> {
66
}
7-
public async down(queryRunner: QueryRunner): Promise<any> {
7+
public async down(queryRunner: QueryRunner): Promise<void> {
88
}
99
}

test/github-issues/2875/migration/1530542855524-CreateUsersSeq.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { MigrationInterface } from "../../../../src/migration/MigrationInterface
22
import { QueryRunner } from "../../../../src/query-runner/QueryRunner";
33

44
export class InitUsers1530542855524 implements MigrationInterface {
5-
public async up(queryRunner: QueryRunner): Promise<any> {
5+
public async up(queryRunner: QueryRunner): Promise<void> {
66
await queryRunner.query(`
77
CREATE SEQUENCE users_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1
88
`);
99
await queryRunner.query(`
1010
DROP SEQUENCE IF EXISTS users_id_seq
1111
`);
1212
}
13-
public async down(queryRunner: QueryRunner): Promise<any> {
13+
public async down(queryRunner: QueryRunner): Promise<void> {
1414
await queryRunner.query(`
1515
DROP SEQUENCE IF EXISTS users_id_seq
1616
`);

test/github-issues/4701/migration/1567759789051-ExampleMigration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { MigrationInterface } from "../../../../src/migration/MigrationInterface
22
import { QueryRunner } from "../../../../src/query-runner/QueryRunner";
33

44
export class ExampleMigrationOne1567759789051 implements MigrationInterface {
5-
public async up(queryRunner: QueryRunner): Promise<any> {}
6-
public async down(queryRunner: QueryRunner): Promise<any> {}
5+
public async up(queryRunner: QueryRunner): Promise<void> {}
6+
public async down(queryRunner: QueryRunner): Promise<void> {}
77
}

test/github-issues/4701/migration/1567759832591-ExampleMigrationTwo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { MigrationInterface } from "../../../../src/migration/MigrationInterface
22
import { QueryRunner } from "../../../../src/query-runner/QueryRunner";
33

44
export class ExampleMigrationOne1567759789051 implements MigrationInterface {
5-
public async up(queryRunner: QueryRunner): Promise<any> {}
6-
public async down(queryRunner: QueryRunner): Promise<any> {}
5+
public async up(queryRunner: QueryRunner): Promise<void> {}
6+
public async down(queryRunner: QueryRunner): Promise<void> {}
77
}

test/github-issues/4701/migration/1571426391120-ExampleMigrationThree.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import { MigrationInterface } from "../../../../src/migration/MigrationInterface
22
import { QueryRunner } from "../../../../src/query-runner/QueryRunner";
33

44
export class ExampleMigrationThree1571426391120 implements MigrationInterface {
5-
public async up(queryRunner: QueryRunner): Promise<any> {}
6-
public async down(queryRunner: QueryRunner): Promise<any> {}
5+
public async up(queryRunner: QueryRunner): Promise<void> {}
6+
public async down(queryRunner: QueryRunner): Promise<void> {}
77
}

0 commit comments

Comments
 (0)