Skip to content

Commit edaf1fb

Browse files
committed
Add ImpersonationAuditLog schema
1 parent 7d29f5a commit edaf1fb

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

internal-packages/database/prisma/schema.prisma

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ model User {
5959
deployments WorkerDeployment[]
6060
backupCodes MfaBackupCode[]
6161
bulkActions BulkActionGroup[]
62+
63+
impersonationsPerformed ImpersonationAuditLog[] @relation("ImpersonationActor")
64+
impersonationsReceived ImpersonationAuditLog[] @relation("ImpersonationTarget")
6265
}
6366

6467
model MfaBackupCode {
@@ -2383,3 +2386,30 @@ model ConnectedGithubRepository {
23832386
@@unique([projectId])
23842387
@@index([repositoryId])
23852388
}
2389+
2390+
enum ImpersonationAuditLogAction {
2391+
START
2392+
STOP
2393+
}
2394+
2395+
model ImpersonationAuditLog {
2396+
id String @id @default(cuid())
2397+
2398+
action ImpersonationAuditLogAction
2399+
2400+
/// The admin user who initiated/ended the impersonation
2401+
actor User @relation("ImpersonationActor", fields: [actorId], references: [id], onDelete: Cascade, onUpdate: Cascade)
2402+
actorId String
2403+
2404+
/// The user being impersonated
2405+
target User @relation("ImpersonationTarget", fields: [targetId], references: [id], onDelete: Cascade, onUpdate: Cascade)
2406+
targetId String
2407+
2408+
ipAddress String?
2409+
2410+
createdAt DateTime @default(now())
2411+
2412+
@@index([actorId])
2413+
@@index([targetId])
2414+
@@index([createdAt])
2415+
}

0 commit comments

Comments
 (0)