1

When two or more migrations are run together during the same task (e.g. migrate up or down), and one fails, only the failed migration is rolled back. I want all the migrations to be rolled back, when one fails.

Example:

export class createRbacs1582769140618 implements MigrationInterface {
    public async up(queryRunner: QueryRunner): Promise<any> {
        await queryRunner.createTable(
            new Table({
                name: "fake_table",
                columns: [
                    {
                        name: "id",
                        type: "int"
                    }
                ]
            })
        );
        await queryRunner.dropTable("not_exits_table");
    }

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

Although migrations task do not record to the migrations table, fake_table still created

Binary Alchemist
  • 1,600
  • 1
  • 13
  • 28

1 Answers1

0

According to typeorm MigrationExecutor, typeorm supports transaction in migration as default.

But if you're using mysql, it can't rollback DDL statements.

bluesh55
  • 81
  • 3