Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update cli migration up and down from any to void #5630

Merged
merged 1 commit into from Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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> {}
}