// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init generator client { provider = "prisma-client" output = "../generated/prisma" } datasource db { provider = "postgresql" } model Session { id String @id @default(uuid()) sessionKey String @unique @default(cuid()) userId String expires DateTime refreshTokenGenerated Boolean @default(false) refreshedAt DateTime? invalidatedAt DateTime? user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model User { id String @id @default(cuid()) roles Role[] permissions String? login String @unique name String? email String @unique emailVerified DateTime? image String? userId String @unique token String? sessions Session[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Role { id String @id @default(uuid()) title String moniker String @unique // e.g. admin, super_admin, moderator permissions String users User[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model UnifiSite { id String @id @default(cuid()) name String siteId String @unique companyId String? company Company? @relation(fields: [companyId], references: [id]) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Company { id String @id @default(cuid()) name String cw_CompanyId Int @unique cw_Identifier String @unique credentials Credential[] unifiSites UnifiSite[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model CredentialType { id String @id @default(cuid()) name String @unique permissionScope String icon String? fields Json credentials Credential[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model SecureValue { id String @id @default(cuid()) name String content String // Encrypted content hash String // Hash of the original content for integrity verification and Search credentialId String credential Credential @relation(fields: [credentialId], references: [id], onDelete: Cascade) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Credential { id String @id @default(cuid()) name String notes String? subCredentialOfId String? subCredentialOf Credential? @relation("SubCredentials", fields: [subCredentialOfId], references: [id], onDelete: Cascade) subCredentials Credential[] @relation("SubCredentials") typeId String type CredentialType @relation(fields: [typeId], references: [id], onDelete: Cascade) fields Json companyId String company Company @relation(fields: [companyId], references: [id], onDelete: Cascade) securevalues SecureValue[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }