We are using TypeORM migrations in one of our NestJS projects.
Following is the example format of migration script that we are using.
import {MigrationInterface, QueryRunner} from "typeorm";
export class VMTestTableTwo1713851442445 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE TABLE "vm_test"(
"aggregate_id" uuid NOT NULL
);
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP TABLE IF EXISTS "vm_test";
`);
}
}
If a up script fails, ideally the down should get executed automatically. But, this is not the case with TypeORM migration. If I am not wrong, Sequelize migration works that way.
How to achieve this in TypeORM migration?