Skip to content
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

feat: track who updated routing form #19079

Merged
3 changes: 3 additions & 0 deletions packages/app-store/routing-forms/trpc/formMutation.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const formMutationHandler = async ({ ctx, input }: FormMutationHandlerOpt
settings: true,
teamId: true,
position: true,
updatedById: true,
},
});

Expand Down Expand Up @@ -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,
},
});

Expand Down Expand Up @@ -269,6 +271,7 @@ export const formMutationHandler = async ({ ctx, input }: FormMutationHandlerOpt
},
data: {
fields: updatedConnectedFormFields,
updatedById: user.id,
},
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/features/insights/server/virtual-queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class VirtualQueuesInsights {
teamId: number | null;
disabled: boolean;
settings: JsonField | null;
updatedById: number | null;
};

const formsRedirectingToWeightedRR: RoutingFormType[] = await prisma.$queryRaw<RoutingFormType[]>`
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 3 additions & 0 deletions packages/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -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)
hariombalhara marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
Loading