Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions backend/src/enums/log-operation-type.enum.ts
Original file line number Diff line number Diff line change
@@ -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',
Comment on lines +9 to +10

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new enum values importRows and exportRows are not being used in the codebase. The ImportCSVInTableUseCase and ExportCSVFromTableUseCase should create log records using these new enum values, similar to how other table operations (addRow, updateRow, deleteRow) create logs. Consider adding logging to these use cases by injecting TableLogsService and creating log records in finally blocks following the established pattern seen in other table use case files.

Copilot uses AI. Check for mistakes.
}
35 changes: 35 additions & 0 deletions backend/src/migrations/1770801552758-AddNewLogOperationTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddNewLogOperationTypes1770801552758 implements MigrationInterface {
name = 'AddNewLogOperationTypes1770801552758';

public async up(queryRunner: QueryRunner): Promise<void> {
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<void> {
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(
Comment on lines +25 to +26

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The down migration could cause data loss. If any table logs have been created with the new enum values (importRows or exportRows), the type conversion at line 27 will fail because these values don't exist in the old enum. Consider adding a data migration step to either delete or convert these records to a safe value like 'unknown' before attempting the type conversion.

Suggested change
await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" DROP DEFAULT`);
await queryRunner.query(
await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" DROP DEFAULT`);
// Ensure there are no values that are invalid for the old enum before casting
await queryRunner.query(
`UPDATE "tableLogs" SET "operationType" = 'unknown' WHERE "operationType" IN ('importRows', 'exportRows')`,
);
await queryRunner.query(

Copilot uses AI. Check for mistakes.
`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"`,
);
}
}
Loading