69 lines
2.1 KiB
Plaintext
69 lines
2.1 KiB
Plaintext
// R-P11b (P11 Dashboard) — typed tenant dashboard layouts.
|
|
//
|
|
// AD-21: self-contained schema. User references are bare String scalars so this
|
|
// slice does not touch accounts/core back-relations while the v1 fixed role
|
|
// layouts stay independent from later drag/drop customization.
|
|
|
|
enum DashboardRole {
|
|
gf
|
|
office
|
|
monteur
|
|
}
|
|
|
|
model Dashboard {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
tenantId String
|
|
name String
|
|
description String?
|
|
role DashboardRole
|
|
isDefaultForRole Boolean @default(true)
|
|
isShared Boolean @default(true)
|
|
isDemoData Boolean @default(false)
|
|
archivedAt DateTime?
|
|
|
|
layouts DashboardLayout[]
|
|
instances WidgetInstance[]
|
|
|
|
@@unique([tenantId, role, name])
|
|
@@index([tenantId, role, isDefaultForRole, archivedAt])
|
|
@@index([tenantId, isShared, archivedAt])
|
|
}
|
|
|
|
model DashboardLayout {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
tenantId String
|
|
dashboardId String
|
|
userId String?
|
|
widgets Json @default("[]")
|
|
layoutData Json @default("{}")
|
|
isDemoData Boolean @default(false)
|
|
archivedAt DateTime?
|
|
|
|
dashboard Dashboard @relation(fields: [dashboardId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([dashboardId, userId])
|
|
@@index([tenantId, dashboardId, userId, archivedAt])
|
|
}
|
|
|
|
model WidgetInstance {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
tenantId String
|
|
dashboardId String
|
|
widgetCatalogKey String
|
|
config Json @default("{}")
|
|
position Json @default("{}")
|
|
size Json @default("{}")
|
|
isDemoData Boolean @default(false)
|
|
archivedAt DateTime?
|
|
|
|
dashboard Dashboard @relation(fields: [dashboardId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([tenantId, dashboardId, widgetCatalogKey, archivedAt])
|
|
}
|