diff --git a/packages/app-store/routing-forms/trpc/formMutation.handler.ts b/packages/app-store/routing-forms/trpc/formMutation.handler.ts index 8054b14514..d36feef631 100644 --- a/packages/app-store/routing-forms/trpc/formMutation.handler.ts +++ b/packages/app-store/routing-forms/trpc/formMutation.handler.ts @@ -63,6 +63,7 @@ export const formMutationHandler = async ({ ctx, input }: FormMutationHandlerOpt settings: true, teamId: true, position: true, + updatedById: true, }, }); @@ -145,6 +146,7 @@ export const formMutationHandler = async ({ ctx, input }: FormMutationHandlerOpt description, settings: settings === null ? Prisma.JsonNull : settings, routes: routes === null ? Prisma.JsonNull : routes, + updatedById: user.id, }, }); @@ -269,6 +271,7 @@ export const formMutationHandler = async ({ ctx, input }: FormMutationHandlerOpt }, data: { fields: updatedConnectedFormFields, + updatedById: user.id, }, }); } diff --git a/packages/features/insights/server/virtual-queues.ts b/packages/features/insights/server/virtual-queues.ts index 672d4683d0..4c07f3439f 100644 --- a/packages/features/insights/server/virtual-queues.ts +++ b/packages/features/insights/server/virtual-queues.ts @@ -18,6 +18,7 @@ class VirtualQueuesInsights { teamId: number | null; disabled: boolean; settings: JsonField | null; + updatedById: number | null; }; const formsRedirectingToWeightedRR: RoutingFormType[] = await prisma.$queryRaw` diff --git a/packages/prisma/migrations/20250204105304_add_updated_by_to_routing_form/migration.sql b/packages/prisma/migrations/20250204105304_add_updated_by_to_routing_form/migration.sql new file mode 100644 index 0000000000..8dec9dcbed --- /dev/null +++ b/packages/prisma/migrations/20250204105304_add_updated_by_to_routing_form/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "App_RoutingForms_Form" ADD COLUMN "updatedById" INTEGER; + +-- AddForeignKey +ALTER TABLE "App_RoutingForms_Form" ADD CONSTRAINT "App_RoutingForms_Form_updatedById_fkey" FOREIGN KEY ("updatedById") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE; diff --git a/packages/prisma/schema.prisma b/packages/prisma/schema.prisma index 52cee38445..e69f513399 100644 --- a/packages/prisma/schema.prisma +++ b/packages/prisma/schema.prisma @@ -339,6 +339,7 @@ model User { ownedEventTypes EventType[] @relation("owner") workflows Workflow[] routingForms App_RoutingForms_Form[] @relation("routing-form") + updatedRoutingForms App_RoutingForms_Form[] @relation("updated-routing-form") verifiedNumbers VerifiedNumber[] verifiedEmails VerifiedEmail[] hosts Host[] @@ -1003,6 +1004,8 @@ model App_RoutingForms_Form { name String fields Json? user User @relation("routing-form", fields: [userId], references: [id], onDelete: Cascade) + updatedBy User? @relation("updated-routing-form", fields: [updatedById], references: [id], onDelete: SetNull) + updatedById Int? // This is the user who created the form and also the user who has read-write access to the form // If teamId is set, the members of the team would also have access to form readOnly or read-write depending on their permission level as team member. userId Int