Multi-environment and multi-user construction
This commit is contained in:
@@ -150,6 +150,7 @@ model Organization {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
users User[]
|
||||
memberships Membership[]
|
||||
orgRoles OrgRole[]
|
||||
companies Company[]
|
||||
people Person[]
|
||||
@@ -227,6 +228,7 @@ model User {
|
||||
reportedTickets Ticket[] @relation("TicketReporter")
|
||||
ticketMessages TicketMessage[] @relation("TicketMessageAuthor")
|
||||
confirmedMemories MemoryItem[] @relation("MemoryConfirmedBy")
|
||||
memberships Membership[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -248,6 +250,7 @@ model OrgRole {
|
||||
/// owner | admin | sales | support — نقشهای سیستمی قابل حذف نیستند
|
||||
systemKey String?
|
||||
users User[]
|
||||
memberships Membership[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@ -255,6 +258,26 @@ model OrgRole {
|
||||
@@index([organizationId])
|
||||
}
|
||||
|
||||
model Membership {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
organizationId String
|
||||
organization Organization @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
role UserRole @default(sales)
|
||||
orgRoleId String?
|
||||
orgRole OrgRole? @relation(fields: [orgRoleId], references: [id], onDelete: SetNull)
|
||||
isActive Boolean @default(true)
|
||||
commissionPercent Decimal @default(0) @db.Decimal(8, 2)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([userId, organizationId])
|
||||
@@index([organizationId, role])
|
||||
@@index([userId])
|
||||
@@index([orgRoleId])
|
||||
}
|
||||
|
||||
model Company {
|
||||
id String @id @default(cuid())
|
||||
organizationId String
|
||||
|
||||
Reference in New Issue
Block a user