|
| 1 | +import { MigrationInterface, QueryRunner } from 'typeorm'; |
| 2 | + |
| 3 | +export class AddNewLogOperationTypes1770801552758 implements MigrationInterface { |
| 4 | + name = 'AddNewLogOperationTypes1770801552758'; |
| 5 | + |
| 6 | + public async up(queryRunner: QueryRunner): Promise<void> { |
| 7 | + await queryRunner.query( |
| 8 | + `ALTER TYPE "public"."tableLogs_operationtype_enum" RENAME TO "tableLogs_operationtype_enum_old"`, |
| 9 | + ); |
| 10 | + await queryRunner.query( |
| 11 | + `CREATE TYPE "public"."tableLogs_operationtype_enum" AS ENUM('addRow', 'updateRow', 'deleteRow', 'unknown', 'rowReceived', 'rowsReceived', 'actionActivated', 'importRows', 'exportRows')`, |
| 12 | + ); |
| 13 | + await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" DROP DEFAULT`); |
| 14 | + await queryRunner.query( |
| 15 | + `ALTER TABLE "tableLogs" ALTER COLUMN "operationType" TYPE "public"."tableLogs_operationtype_enum" USING "operationType"::"text"::"public"."tableLogs_operationtype_enum"`, |
| 16 | + ); |
| 17 | + await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" SET DEFAULT 'unknown'`); |
| 18 | + await queryRunner.query(`DROP TYPE "public"."tableLogs_operationtype_enum_old"`); |
| 19 | + } |
| 20 | + |
| 21 | + public async down(queryRunner: QueryRunner): Promise<void> { |
| 22 | + await queryRunner.query( |
| 23 | + `CREATE TYPE "public"."tableLogs_operationtype_enum_old" AS ENUM('addRow', 'updateRow', 'deleteRow', 'unknown', 'rowReceived', 'rowsReceived', 'actionActivated')`, |
| 24 | + ); |
| 25 | + await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" DROP DEFAULT`); |
| 26 | + await queryRunner.query( |
| 27 | + `ALTER TABLE "tableLogs" ALTER COLUMN "operationType" TYPE "public"."tableLogs_operationtype_enum_old" USING "operationType"::"text"::"public"."tableLogs_operationtype_enum_old"`, |
| 28 | + ); |
| 29 | + await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" SET DEFAULT 'unknown'`); |
| 30 | + await queryRunner.query(`DROP TYPE "public"."tableLogs_operationtype_enum"`); |
| 31 | + await queryRunner.query( |
| 32 | + `ALTER TYPE "public"."tableLogs_operationtype_enum_old" RENAME TO "tableLogs_operationtype_enum"`, |
| 33 | + ); |
| 34 | + } |
| 35 | +} |
0 commit comments