add log for sign in, sign out, change password, remove upload file
This commit is contained in:
16
prisma/migrations/20260108130508_audit/migration.sql
Normal file
16
prisma/migrations/20260108130508_audit/migration.sql
Normal file
@@ -0,0 +1,16 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "audit" (
|
||||
"id" TEXT NOT NULL,
|
||||
"userId" TEXT NOT NULL,
|
||||
"action" TEXT NOT NULL,
|
||||
"tableName" TEXT NOT NULL,
|
||||
"recordId" TEXT NOT NULL,
|
||||
"oldValue" TEXT,
|
||||
"newValue" TEXT,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "audit_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "audit" ADD CONSTRAINT "audit_userId_fkey" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -18,6 +18,7 @@ model User {
|
||||
updatedAt DateTime @updatedAt
|
||||
sessions Session[]
|
||||
accounts Account[]
|
||||
audit Audit[]
|
||||
|
||||
role String?
|
||||
banned Boolean? @default(false)
|
||||
@@ -142,3 +143,18 @@ model Setting {
|
||||
|
||||
@@map("setting")
|
||||
}
|
||||
|
||||
model Audit {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
action String
|
||||
tableName String
|
||||
recordId String
|
||||
oldValue String?
|
||||
newValue String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("audit")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user