mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 22:58:17 +00:00
Merge pull request #1338 from Tria-plc/alpha
feat: ( audit ) resolve the actor from the session and audit all back…
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
-- The audit trail has to answer "who did this" without a cross-schema join: Prisma only knows
|
||||
-- the `passenger` schema, and an IAM user that is later deleted would take the answer with it.
|
||||
-- So the actor's name and phone are denormalized onto the row at write time, the same way
|
||||
-- SeatBlock.blockedByName was added for the blocked-seat report.
|
||||
--
|
||||
-- Purely additive: both columns are nullable and the index is new, so rows written before this
|
||||
-- migration keep working and simply report as System / Unknown in the backoffice.
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "passenger"."AuditLog"
|
||||
ADD COLUMN IF NOT EXISTS "userName" TEXT,
|
||||
ADD COLUMN IF NOT EXISTS "userPhone" TEXT;
|
||||
|
||||
-- CreateIndex: the default Audit Logs listing sorts createdAt DESC with no other filter, which
|
||||
-- neither existing composite index serves. Broadening audit coverage materially increases the
|
||||
-- row count behind that sort.
|
||||
CREATE INDEX IF NOT EXISTS "AuditLog_createdAt_idx" ON "passenger"."AuditLog"("createdAt");
|
||||
@@ -1325,6 +1325,11 @@ model ExcessBaggageCharge {
|
||||
model AuditLog {
|
||||
id String @id @default(uuid())
|
||||
iamUserId String?
|
||||
/// Actor's display name, denormalized at write time so a reader needs no cross-schema
|
||||
/// lookup into iam.users and the trail survives the IAM user being deleted.
|
||||
userName String?
|
||||
/// Actor's contact number, denormalized for the same reason.
|
||||
userPhone String?
|
||||
action String
|
||||
entityType String
|
||||
entityId String?
|
||||
@@ -1335,6 +1340,7 @@ model AuditLog {
|
||||
createdAt DateTime @default(now())
|
||||
@@index([iamUserId, createdAt])
|
||||
@@index([entityType, entityId])
|
||||
@@index([createdAt])
|
||||
@@schema("passenger")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user