PrismaP
Prisma12mo ago
7 replies
Yoni

Audit Logging

Hello prisma people. I would like to setup Audit logging on all of the tables in my DB. On the prisma docs/github I see two main ways to achieve this:

1. Using prisma client extensions.
2. Using custom triggers from migrations + client extensions. (~2 years old)

First issue is that I am using in some places the prisma.$transaction() function, which apparently is not happy when I try to create the extension on the client for it. Then, the second and last issue I am running into is linking the change in the audit table to the user responsible for this change. I see that in the example provided here: https://github.com/prisma/prisma-client-extensions/tree/main/audit-log-context#2-create-audit-log-triggers, that the "current user" being sent to log in the audit table is sent through client extensions and that seems to be one of the ways to achieve this.

Anyways, what is the most up to date and proper way to do this? Furthermore, is there a fix for auditing queries done with the transaction client?

Thank you!
Was this page helpful?