Initial SuperAdmin API (NestJS + Prisma)
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
// Local scaffold default: SQLite. For MySQL set provider = "mysql" and DATABASE_URL accordingly.
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
enum ProductType {
|
||||
hamkar
|
||||
khanegi
|
||||
}
|
||||
|
||||
enum UserRole {
|
||||
super_admin
|
||||
viewer
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
email String @unique
|
||||
passwordHash String @map("password_hash")
|
||||
name String
|
||||
role UserRole @default(super_admin)
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
auditLogs AuditLog[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model Tenant {
|
||||
id String @id @default(cuid())
|
||||
product ProductType
|
||||
slug String @unique
|
||||
nameFa String @map("name_fa")
|
||||
nameEn String? @map("name_en")
|
||||
domain String @unique
|
||||
domains Json?
|
||||
avatarUrl String? @map("avatar_url")
|
||||
primaryColor String? @map("primary_color")
|
||||
secondaryColor String? @map("secondary_color")
|
||||
backgroundColor String? @map("background_color")
|
||||
nodeServer String @map("node_server")
|
||||
nodeWs String? @map("node_ws")
|
||||
appUrl String? @map("app_url")
|
||||
adminUrl String? @map("admin_url")
|
||||
remoteApiToken String? @map("remote_api_token")
|
||||
/// Full Khanegi UI JSON (theme, navigation, pages). Hamkar: unused for now.
|
||||
appUiConfig Json? @map("app_ui_config")
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
notes String?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
auditLogs AuditLog[]
|
||||
|
||||
@@index([product])
|
||||
@@index([isActive])
|
||||
@@map("tenants")
|
||||
}
|
||||
|
||||
model AuditLog {
|
||||
id String @id @default(cuid())
|
||||
action String
|
||||
entityType String @map("entity_type")
|
||||
entityId String? @map("entity_id")
|
||||
tenantId String? @map("tenant_id")
|
||||
userId String? @map("user_id")
|
||||
before Json?
|
||||
after Json?
|
||||
meta Json?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
tenant Tenant? @relation(fields: [tenantId], references: [id], onDelete: SetNull)
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([tenantId])
|
||||
@@index([userId])
|
||||
@@index([createdAt])
|
||||
@@map("audit_logs")
|
||||
}
|
||||
Reference in New Issue
Block a user