feat: add new log operation types to enum and migration#1590
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds two new log operation types (importRows and exportRows) to the LogOperationTypeEnum to support logging of CSV import and export operations. The changes include updating the TypeScript enum definition and creating a database migration to add these values to the PostgreSQL enum type.
Changes:
- Added
importRowsandexportRowsenum values toLogOperationTypeEnum - Created a migration to alter the database enum type to include the new values
- Reformatted the enum file from spaces to tabs (whitespace consistency)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| backend/src/enums/log-operation-type.enum.ts | Added two new enum values (importRows, exportRows) and standardized indentation to tabs |
| backend/src/migrations/1770801552758-AddNewLogOperationTypes.ts | Database migration to add new operation types to the tableLogs operationType enum |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await queryRunner.query(`ALTER TABLE "tableLogs" ALTER COLUMN "operationType" DROP DEFAULT`); | ||
| await queryRunner.query( |
There was a problem hiding this comment.
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.
| 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( |
| importRows = 'importRows', | ||
| exportRows = 'exportRows', |
There was a problem hiding this comment.
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.
No description provided.