-
-
Notifications
You must be signed in to change notification settings - Fork 18
feat: add new log operation types to enum and migration #1590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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', | ||
| } | ||
| 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
|
||||||||||||||||||
| 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( |
There was a problem hiding this comment.
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.