diff --git a/services/workflows-service/prisma/migrations/20240311093641_fix_relations_for_transaction_monitoring/migration.sql b/services/workflows-service/prisma/migrations/20240311093641_fix_relations_for_transaction_monitoring/migration.sql new file mode 100644 index 0000000000..8437a89719 --- /dev/null +++ b/services/workflows-service/prisma/migrations/20240311093641_fix_relations_for_transaction_monitoring/migration.sql @@ -0,0 +1,22 @@ +/* + Warnings: + + - You are about to drop the column `businessId` on the `Alert` table. All the data in the column will be lost. + - You are about to drop the column `endUserId` on the `Alert` table. All the data in the column will be lost. + +*/ +-- DropForeignKey +ALTER TABLE "Alert" DROP CONSTRAINT "Alert_businessId_fkey"; + +-- DropForeignKey +ALTER TABLE "Alert" DROP CONSTRAINT "Alert_endUserId_fkey"; + +-- DropIndex +DROP INDEX "Alert_businessId_idx"; + +-- DropIndex +DROP INDEX "Alert_endUserId_idx"; + +-- AlterTable +ALTER TABLE "Alert" DROP COLUMN "businessId", +DROP COLUMN "endUserId"; diff --git a/services/workflows-service/prisma/schema.prisma b/services/workflows-service/prisma/schema.prisma index baa11fce6f..8b2fe86e50 100644 --- a/services/workflows-service/prisma/schema.prisma +++ b/services/workflows-service/prisma/schema.prisma @@ -84,7 +84,6 @@ model EndUser { projectId String project Project @relation(fields: [projectId], references: [id]) WorkflowRuntimeDataToken WorkflowRuntimeDataToken[] - Alert Alert[] Counterparty Counterparty[] @@unique([projectId, correlationId]) @@ -141,7 +140,6 @@ model Business { projectId String project Project @relation(fields: [projectId], references: [id]) - Alert Alert[] Counterparty Counterparty[] @@unique([projectId, correlationId]) @@ -684,12 +682,6 @@ model Alert { projectId String project Project @relation(fields: [projectId], references: [id], onUpdate: Cascade, onDelete: NoAction) - businessId String? - business Business? @relation(fields: [businessId], references: [id], onUpdate: Cascade, onDelete: NoAction) - - endUserId String? - endUser EndUser? @relation(fields: [endUserId], references: [id], onUpdate: Cascade, onDelete: NoAction) - dataTimestamp DateTime state AlertState status AlertStatus @@ -712,8 +704,6 @@ model Alert { counterparty Counterparty? @relation(fields: [counterpartyId], references: [id]) @@index([assigneeId]) - @@index([businessId]) - @@index([endUserId]) @@index([projectId]) @@index([alertDefinitionId]) @@index([counterpartyId]) diff --git a/services/workflows-service/src/alert/alert.controller.external.ts b/services/workflows-service/src/alert/alert.controller.external.ts index 6e130cb903..06626ef8a8 100644 --- a/services/workflows-service/src/alert/alert.controller.external.ts +++ b/services/workflows-service/src/alert/alert.controller.external.ts @@ -65,10 +65,22 @@ export class AlertControllerExternal { lastName: true, }, }, - business: { + counterparty: { select: { id: true, - companyName: true, + business: { + select: { + id: true, + companyName: true, + }, + }, + endUser: { + select: { + id: true, + firstName: true, + lastName: true, + }, + }, }, }, }, diff --git a/services/workflows-service/src/alert/alert.service.ts b/services/workflows-service/src/alert/alert.service.ts index 20159da964..3da37c9b35 100644 --- a/services/workflows-service/src/alert/alert.service.ts +++ b/services/workflows-service/src/alert/alert.service.ts @@ -208,7 +208,7 @@ export class AlertService { private createAlert( alertDef: AlertDefinition, - data: Pick, + data: Pick, ): Promise { return this.alertRepository.create({ data: {