Skip to content

Commit

Permalink
feat: update cli migration up and down from any to void (#5630)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexandre Piel <alexandre.piel@zooplus.com>
  • Loading branch information
apiel and Alexandre Piel committed Mar 11, 2020
1 parent 0adbe5c commit 76e165d
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 92 deletions.
140 changes: 70 additions & 70 deletions docs/migrations.md

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions docs/zh_CN/migrations.md
Expand Up @@ -94,9 +94,9 @@ typeorm migration:create -n PostRefactoring
import { MigrationInterface, QueryRunner } from "typeorm";

export class PostRefactoringTIMESTAMP implements MigrationInterface {
async up(queryRunner: QueryRunner): Promise<any> {}
async up(queryRunner: QueryRunner): Promise<void> {}

async down(queryRunner: QueryRunner): Promise<any> {}
async down(queryRunner: QueryRunner): Promise<void> {}
}
```

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

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

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

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

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

export class QuestionRefactoringTIMESTAMP implements MigrationInterface {
async up(queryRunner: QueryRunner): Promise<any> {
async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: "question",
Expand Down Expand Up @@ -258,7 +258,7 @@ export class QuestionRefactoringTIMESTAMP implements MigrationInterface {
);
}

async down(queryRunner: QueryRunner): Promise<any> {
async down(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable("question");
const foreignKey = table.foreignKeys.find(fk => fk.columnNames.indexOf("questionId") !== -1);
await queryRunner.dropForeignKey("question", foreignKey);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/MigrationCreateCommand.ts
Expand Up @@ -82,10 +82,10 @@ export class MigrationCreateCommand implements yargs.CommandModule {
export class ${camelCase(name, true)}${timestamp} implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
public async up(queryRunner: QueryRunner): Promise<void> {
}
public async down(queryRunner: QueryRunner): Promise<any> {
public async down(queryRunner: QueryRunner): Promise<void> {
}
}
Expand Down
Expand Up @@ -2,8 +2,8 @@ import { MigrationInterface } from "../../../../../src/migration/MigrationInterf
import { QueryRunner } from "../../../../../src/query-runner/QueryRunner";

export class ExampleMigration1530542855524 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
public async up(queryRunner: QueryRunner): Promise<void> {
}
public async down(queryRunner: QueryRunner): Promise<any> {
public async down(queryRunner: QueryRunner): Promise<void> {
}
}
Expand Up @@ -2,8 +2,8 @@ import { MigrationInterface } from "../../../../../src/migration/MigrationInterf
import { QueryRunner } from "../../../../../src/query-runner/QueryRunner";

export class ExampleMigrationTwo1530542855524 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
public async up(queryRunner: QueryRunner): Promise<void> {
}
public async down(queryRunner: QueryRunner): Promise<any> {
public async down(queryRunner: QueryRunner): Promise<void> {
}
}
Expand Up @@ -2,15 +2,15 @@ import { MigrationInterface } from "../../../../src/migration/MigrationInterface
import { QueryRunner } from "../../../../src/query-runner/QueryRunner";

export class InitUsers1530542855524 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE SEQUENCE users_id_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1
`);
await queryRunner.query(`
DROP SEQUENCE IF EXISTS users_id_seq
`);
}
public async down(queryRunner: QueryRunner): Promise<any> {
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP SEQUENCE IF EXISTS users_id_seq
`);
Expand Down
Expand Up @@ -2,6 +2,6 @@ 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> {}
public async up(queryRunner: QueryRunner): Promise<void> {}
public async down(queryRunner: QueryRunner): Promise<void> {}
}
Expand Up @@ -2,6 +2,6 @@ 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> {}
public async up(queryRunner: QueryRunner): Promise<void> {}
public async down(queryRunner: QueryRunner): Promise<void> {}
}
Expand Up @@ -2,6 +2,6 @@ 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> {}
public async up(queryRunner: QueryRunner): Promise<void> {}
public async down(queryRunner: QueryRunner): Promise<void> {}
}

0 comments on commit 76e165d

Please sign in to comment.