generator client { provider = "prisma-client-js" } datasource db { provider = "sqlite" url = env("DATABASE_URL") } model User { id String @id @default(cuid()) email String @unique passwordHash String firstName String lastName String isActive Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt userRoles UserRole[] } model Role { id String @id @default(cuid()) name String @unique description String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt userRoles UserRole[] rolePermissions RolePermission[] } model Permission { id String @id @default(cuid()) key String @unique description String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt rolePermissions RolePermission[] } model UserRole { userId String roleId String assignedAt DateTime @default(now()) assignedBy String? role Role @relation(fields: [roleId], references: [id], onDelete: Cascade) user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@id([userId, roleId]) } model RolePermission { roleId String permissionId String grantedAt DateTime @default(now()) permission Permission @relation(fields: [permissionId], references: [id], onDelete: Cascade) role Role @relation(fields: [roleId], references: [id], onDelete: Cascade) @@id([roleId, permissionId]) } model CompanyProfile { id String @id @default(cuid()) companyName String legalName String email String phone String website String taxId String addressLine1 String addressLine2 String city String state String postalCode String country String primaryColor String @default("#185ADB") accentColor String @default("#00A6A6") surfaceColor String @default("#F4F7FB") fontFamily String @default("Manrope") logoFileId String? @unique isActive Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt logoFile FileAttachment? @relation("CompanyLogo", fields: [logoFileId], references: [id], onDelete: SetNull) } model FileAttachment { id String @id @default(cuid()) originalName String storedName String mimeType String sizeBytes Int relativePath String ownerType String ownerId String createdById String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt companyLogoFor CompanyProfile? @relation("CompanyLogo") } model Customer { id String @id @default(cuid()) name String email String phone String addressLine1 String addressLine2 String city String state String postalCode String country String notes String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Vendor { id String @id @default(cuid()) name String email String phone String addressLine1 String addressLine2 String city String state String postalCode String country String notes String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }