Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/prisma/schema/admin.prisma
T

51 lines
2.4 KiB
Plaintext

// AK-P19 — Platform-Admin module (admin.hivegrid.de).
//
// Per AD-21 each module owns its own schema file. The platform-admin
// world is deliberately a *separate* world: these rows carry NO
// `tenant_id`-based RLS scoping of their own beyond a plain FK, because
// admin actions span tenants. Cross-tenant admin actions are recorded
// through the shared append-only AuditEvent Querschnitt (tenantId=null,
// actorType="admin") — NOT a parallel audit table. All authors reference
// the tenant-less AdminUser identity from adminIdentity.prisma.
/// AdminTenantNote — free-form operator notes pinned to a tenant.
/// ENTITY-MODEL Domäne 11: markdown note_text, category, pinned.
/// Written from the admin tenant-detail screen; every write also emits
/// an admin AuditEvent (tenantId=null, actorType="admin").
model AdminTenantNote {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
tenantId String
authorUserId String?
noteText String
category String @default("general")
pinned Boolean @default(false)
tenant Tenant @relation(fields: [tenantId], references: [id], onDelete: Cascade)
author AdminUser? @relation("adminTenantNoteAuthor", fields: [authorUserId], references: [id], onDelete: SetNull)
// Detail view lists pinned-first, newest-first, per tenant.
@@index([tenantId, pinned, createdAt], name: "admin_tenant_note_tenant_pinned_created_idx")
@@index([tenantId, category], name: "admin_tenant_note_tenant_category_idx")
}
/// SupportTicketMessage — conversation thread for the admin Support-Inbox.
/// Extends the existing helpDesk `SupportTicket` (which already carries
/// source/status/priority/tenant) with replies and internal notes.
/// `internalNote=true` rows are operator-only and never surfaced to the
/// tenant. A null author means an inbound message from the customer side.
model SupportTicketMessage {
id String @id @default(cuid())
createdAt DateTime @default(now())
supportTicketId String
authorUserId String?
body String
internalNote Boolean @default(false)
ticket SupportTicket @relation(fields: [supportTicketId], references: [id], onDelete: Cascade)
author AdminUser? @relation("supportTicketMessageAuthor", fields: [authorUserId], references: [id], onDelete: SetNull)
@@index([supportTicketId, createdAt], name: "support_ticket_message_ticket_created_idx")
}