initial: standalone repo from monorepo split
This commit is contained in:
133
packages/admin-db/prisma/schema.prisma
Normal file
133
packages/admin-db/prisma/schema.prisma
Normal file
@@ -0,0 +1,133 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
output = "../generated"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_ADMIN_URL")
|
||||
}
|
||||
|
||||
// ─── Platform SuperAdmins ────────────────────────────
|
||||
|
||||
model SuperAdmin {
|
||||
id String @id @default(uuid())
|
||||
email String @unique
|
||||
password String
|
||||
firstName String
|
||||
lastName String
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
refreshTokens AdminRefreshToken[]
|
||||
auditLogs PlatformAuditLog[]
|
||||
assignedTickets SupportTicket[] @relation("TicketAssignee")
|
||||
ticketComments SupportTicketComment[]
|
||||
|
||||
@@map("super_admins")
|
||||
}
|
||||
|
||||
model AdminRefreshToken {
|
||||
id String @id @default(uuid())
|
||||
token String @unique
|
||||
adminId String
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
admin SuperAdmin @relation(fields: [adminId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([adminId])
|
||||
@@index([expiresAt])
|
||||
@@map("admin_refresh_tokens")
|
||||
}
|
||||
|
||||
// ─── Platform Audit Log ──────────────────────────────
|
||||
|
||||
model PlatformAuditLog {
|
||||
id String @id @default(uuid())
|
||||
adminId String
|
||||
action String
|
||||
target String?
|
||||
details Json @default("{}")
|
||||
ipAddress String?
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
admin SuperAdmin @relation(fields: [adminId], references: [id])
|
||||
|
||||
@@index([adminId])
|
||||
@@index([action])
|
||||
@@index([target])
|
||||
@@index([createdAt])
|
||||
@@map("platform_audit_logs")
|
||||
}
|
||||
|
||||
// ─── Support Tickets (Tenant → Platform) ─────────────
|
||||
|
||||
model SupportTicket {
|
||||
id String @id @default(uuid())
|
||||
tenantId String
|
||||
tenantName String
|
||||
tenantSlug String
|
||||
createdById String
|
||||
createdByName String
|
||||
subject String
|
||||
description String
|
||||
category String @default("general") // billing, technical, account, general, feature_request
|
||||
priority String @default("normal") // low, normal, high, urgent
|
||||
status String @default("open") // open, in_progress, waiting_tenant, resolved, closed
|
||||
assignedToId String?
|
||||
resolvedAt DateTime?
|
||||
closedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
assignee SuperAdmin? @relation("TicketAssignee", fields: [assignedToId], references: [id])
|
||||
comments SupportTicketComment[]
|
||||
attachments SupportTicketAttachment[]
|
||||
|
||||
@@index([tenantId])
|
||||
@@index([status])
|
||||
@@index([category])
|
||||
@@index([priority])
|
||||
@@index([assignedToId])
|
||||
@@index([createdAt])
|
||||
@@map("support_tickets")
|
||||
}
|
||||
|
||||
model SupportTicketComment {
|
||||
id String @id @default(uuid())
|
||||
ticketId String
|
||||
authorId String
|
||||
authorName String
|
||||
authorType String // "super_admin" or "tenant_user"
|
||||
content String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
ticket SupportTicket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
||||
author SuperAdmin? @relation(fields: [authorId], references: [id])
|
||||
attachments SupportTicketAttachment[]
|
||||
|
||||
@@index([ticketId])
|
||||
@@index([authorId])
|
||||
@@map("support_ticket_comments")
|
||||
}
|
||||
|
||||
model SupportTicketAttachment {
|
||||
id String @id @default(uuid())
|
||||
ticketId String
|
||||
commentId String?
|
||||
fileName String
|
||||
originalName String
|
||||
mimeType String
|
||||
sizeBytes Int
|
||||
uploadedBy String
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
ticket SupportTicket @relation(fields: [ticketId], references: [id], onDelete: Cascade)
|
||||
comment SupportTicketComment? @relation(fields: [commentId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([ticketId])
|
||||
@@index([commentId])
|
||||
@@map("support_ticket_attachments")
|
||||
}
|
||||
Reference in New Issue
Block a user