diff --git a/backend/src/enums/log-operation-type.enum.ts b/backend/src/enums/log-operation-type.enum.ts index 3f7f2a468..4c1d702d5 100644 --- a/backend/src/enums/log-operation-type.enum.ts +++ b/backend/src/enums/log-operation-type.enum.ts @@ -1,9 +1,11 @@ export enum LogOperationTypeEnum { - addRow = 'addRow', - updateRow = 'updateRow', - deleteRow = 'deleteRow', - unknown = 'unknown', - rowReceived = 'rowReceived', - rowsReceived = 'rowsReceived', - actionActivated = 'actionActivated', + addRow = 'addRow', + updateRow = 'updateRow', + deleteRow = 'deleteRow', + unknown = 'unknown', + rowReceived = 'rowReceived', + rowsReceived = 'rowsReceived', + actionActivated = 'actionActivated', + importRows = 'importRows', + exportRows = 'exportRows', } diff --git a/backend/src/migrations/1770801552758-AddNewLogOperationTypes.ts b/backend/src/migrations/1770801552758-AddNewLogOperationTypes.ts new file mode 100644 index 000000000..86d3ab298 --- /dev/null +++ b/backend/src/migrations/1770801552758-AddNewLogOperationTypes.ts @@ -0,0 +1,35 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddNewLogOperationTypes1770801552758 implements MigrationInterface { + name = 'AddNewLogOperationTypes1770801552758'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TYPE "public"."tableLogs_operationtype_enum" RENAME TO "tableLogs_operationtype_enum_old"`, + ); + await queryRunner.query( + `CREATE TYPE "public"."tableLogs_operationtype_enum" AS ENUM('addRow', 'updateRow', 'deleteRow', 'unknown', 'rowReceived', 'rowsReceived', 'actionActivated', 'importRows', 'exportRows')`, + ); + await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" DROP DEFAULT`); + await queryRunner.query( + `ALTER TABLE "tableLogs" ALTER COLUMN "operationType" TYPE "public"."tableLogs_operationtype_enum" USING "operationType"::"text"::"public"."tableLogs_operationtype_enum"`, + ); + await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" SET DEFAULT 'unknown'`); + await queryRunner.query(`DROP TYPE "public"."tableLogs_operationtype_enum_old"`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `CREATE TYPE "public"."tableLogs_operationtype_enum_old" AS ENUM('addRow', 'updateRow', 'deleteRow', 'unknown', 'rowReceived', 'rowsReceived', 'actionActivated')`, + ); + await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" DROP DEFAULT`); + await queryRunner.query( + `ALTER TABLE "tableLogs" ALTER COLUMN "operationType" TYPE "public"."tableLogs_operationtype_enum_old" USING "operationType"::"text"::"public"."tableLogs_operationtype_enum_old"`, + ); + await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" SET DEFAULT 'unknown'`); + await queryRunner.query(`DROP TYPE "public"."tableLogs_operationtype_enum"`); + await queryRunner.query( + `ALTER TYPE "public"."tableLogs_operationtype_enum_old" RENAME TO "tableLogs_operationtype_enum"`, + ); + } +}