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:
Abubeker Yasin
2026-08-18 16:19:15 +03:00
committed by GitHub
32 changed files with 3068 additions and 420 deletions

View File

@@ -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");

View File

@@ -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")
}