generator client { provider = "prisma-client-js" previewFeatures = ["driverAdapters"] } datasource db { provider = "sqlite" url = env("DATABASE_URL") } model Space { id String @id @default(uuid()) roomId String @unique smsPhone String wbxTmPhone String smsName String title String createdAt DateTime @default(now()) updatedAt DateTime @updatedAt messages Message[] bulkJobs BulkJob[] surveys Survey[] pendingMessages PendingMessage[] @@index([smsPhone, wbxTmPhone]) } model Contact { id String @id @default(uuid()) name String phone String @unique blocked Boolean @default(false) blockReason String? createdAt DateTime @default(now()) } model Message { id String @id @default(uuid()) sid String? @unique roomId String from String // person email or phone body String mediaUrls String // JSON stringified array e.g. '["url1", "url2"]' status String // sent, delivered, failed, undelivered, etc. createdAt DateTime @default(now()) space Space? @relation(fields: [roomId], references: [roomId], onDelete: Cascade) @@index([roomId]) @@index([createdAt]) } model BulkJob { id String @id @default(uuid()) parentId String senderEmail String text String files String // JSON stringified array of file URLs/paths status String @default("pending") analytics Json? sentAt DateTime? completedAt DateTime? spaceId String? space Space? @relation(fields: [spaceId], references: [id], onDelete: Cascade) } model Survey { id String @id @default(uuid()) roomId String question String endDate DateTime responses String // JSON stringified array of {phone, response} completed Boolean @default(false) space Space? @relation(fields: [roomId], references: [roomId], onDelete: Cascade) } model OutboundRouting { email String @id phoneNumber String groups String // JSON stringified array e.g. '["ottawa", "hazleton"]' } model InboundRouting { phoneNumber String @id site String people String // JSON stringified array keywords Json? outOfOffice Json? } model BlockNumber { phoneNumber String @id name String reason String createdAt DateTime @default(now()) } // Tracks SMS sends that are waiting for the user to upload an attachment in Webex. // Used by the PendingMessageStore service. One row per room (overwrites previous). model PendingMessage { roomId String @id text String createdAt DateTime @default(now()) space Space? @relation(fields: [roomId], references: [roomId], onDelete: Cascade) }