🚩 (role) create user role assignment module

create module for assign to user and unassign role from user
This commit is contained in:
Rafi Arrafif
2025-07-15 10:25:22 +07:00
parent 6decfe0c93
commit 1811d1dcc8
13 changed files with 96 additions and 88 deletions

View File

@ -201,7 +201,7 @@ model User {
gender UserGender?
phoneCC Int?
phoneNumber Int?
roles UserRole[] @relation("UserRoles")
roles UserRoleAssignment[]
bioProfile String? @db.Text
avatar String? @db.Text
commentBackground String? @db.Text
@ -284,10 +284,23 @@ model UserRole {
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
users User[] @relation("UserRoles")
users UserRoleAssignment[]
@@map("user_roles")
}
model UserRoleAssignment {
user User @relation(fields: [userId], references: [id])
userId String
role UserRole @relation(fields: [roleId], references: [id])
roleId String
assignmentAt DateTime @default(now())
@@id([userId, roleId])
@@map("user_role_assignments")
}
model UserNotification {
id String @id @default(uuid())
title String @db.VarChar(255)