generator client { provider = "prisma-client-js" previewFeatures = ["metrics"] } datasource db { provider = "postgresql" url = env("DATABASE_URL") } model Account { id String @id @default(cuid()) userId String type String provider String providerAccountId String refresh_token String? access_token String? expires_at Int? token_type String? scope String? id_token String? session_state String? oauth_token_secret String? oauth_token String? refresh_token_expires_in Int? user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([provider, providerAccountId]) } model Session { id String @id @default(cuid()) sessionToken String @unique userId String expires DateTime user User @relation(fields: [userId], references: [id], onDelete: Cascade) } model User { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt lastActivityAt DateTime @default(now()) name String? email String? @unique emailVerified DateTime? image String? company String? onboardingCategories Json referral String? graphNavigation GraphNavigation? preferredAppAppearance String? accounts Account[] apiTokens ApiToken[] CollaboratorsOnTypebots CollaboratorsOnTypebots[] workspaces MemberInWorkspace[] sessions Session[] bannedIps BannedIp[] displayedInAppNotifications Json? } model ApiToken { id String @id @default(cuid()) createdAt DateTime @default(now()) token String @unique name String ownerId String owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade) } model Workspace { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt name String icon String? plan Plan @default(FREE) stripeId String? @unique credentials Credentials[] customDomains CustomDomain[] folders DashboardFolder[] members MemberInWorkspace[] typebots Typebot[] invitations WorkspaceInvitation[] additionalChatsIndex Int @default(0) additionalStorageIndex Int @default(0) chatsLimitFirstEmailSentAt DateTime? storageLimitFirstEmailSentAt DateTime? chatsLimitSecondEmailSentAt DateTime? storageLimitSecondEmailSentAt DateTime? claimableCustomPlan ClaimableCustomPlan? customChatsLimit Int? customStorageLimit Int? customSeatsLimit Int? isQuarantined Boolean @default(false) isSuspended Boolean @default(false) isPastDue Boolean @default(false) isVerified Boolean? themeTemplates ThemeTemplate[] } model MemberInWorkspace { createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt userId String workspaceId String role WorkspaceRole user User @relation(fields: [userId], references: [id], onDelete: Cascade) workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade) @@unique([userId, workspaceId]) } model WorkspaceInvitation { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt email String workspaceId String type WorkspaceRole workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade) } model CustomDomain { name String @id createdAt DateTime @default(now()) workspaceId String workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade) } model Credentials { id String @id @default(cuid()) createdAt DateTime @default(now()) workspaceId String data String name String type String iv String workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade) } model VerificationToken { identifier String token String @unique expires DateTime @@unique([identifier, token]) } model DashboardFolder { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt name String parentFolderId String? workspaceId String parentFolder DashboardFolder? @relation("ParentChild", fields: [parentFolderId], references: [id]) workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade) childrenFolder DashboardFolder[] @relation("ParentChild") typebots Typebot[] } model Typebot { id String @id @default(cuid()) version String? createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt icon String? name String folderId String? groups Json events Json? variables Json edges Json theme Json selectedThemeTemplateId String? settings Json publicId String? @unique customDomain String? @unique workspaceId String resultsTablePreferences Json? folder DashboardFolder? @relation(fields: [folderId], references: [id]) workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade) collaborators CollaboratorsOnTypebots[] invitations Invitation[] publishedTypebot PublicTypebot? results Result[] webhooks Webhook[] isArchived Boolean @default(false) isClosed Boolean @default(false) whatsAppCredentialsId String? riskLevel Int? bannedIps BannedIp[] @@index([workspaceId]) @@index([isArchived, createdAt(sort: Desc)]) } model Invitation { createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt email String typebotId String type CollaborationType typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade) @@unique([email, typebotId]) } model CollaboratorsOnTypebots { createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt userId String typebotId String type CollaborationType typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade) user User @relation(fields: [userId], references: [id], onDelete: Cascade) @@unique([userId, typebotId]) } model PublicTypebot { id String @id @default(cuid()) version String? createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt typebotId String @unique groups Json events Json? variables Json edges Json theme Json settings Json typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade) } model Result { id String @id @default(cuid()) createdAt DateTime @default(now()) typebotId String variables Json isCompleted Boolean hasStarted Boolean? isArchived Boolean? @default(false) lastChatSessionId String? typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade) answers Answer[] answersV2 AnswerV2[] logs Log[] edges VisitedEdge[] setVariableHistory SetVariableHistoryItem[] @@index([typebotId, hasStarted, createdAt(sort: Desc)]) @@index([typebotId, isCompleted]) } model SetVariableHistoryItem { result Result @relation(fields: [resultId], references: [id], onDelete: Cascade) resultId String index Int variableId String blockId String value Json // string or list @@unique([resultId, index]) } model VisitedEdge { result Result @relation(fields: [resultId], references: [id], onDelete: Cascade) resultId String edgeId String index Int @@unique([resultId, index]) } model Log { id String @id @default(cuid()) createdAt DateTime @default(now()) resultId String status String description String details String? result Result @relation(fields: [resultId], references: [id], onDelete: Cascade) @@index([resultId]) } model Answer { createdAt DateTime @default(now()) @updatedAt resultId String blockId String groupId String variableId String? content String result Result @relation(fields: [resultId], references: [id], onDelete: Cascade) @@unique([resultId, blockId, groupId]) } model AnswerV2 { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) blockId String content String attachedFileUrls Json? resultId String result Result @relation(fields: [resultId], references: [id], onDelete: Cascade) @@index([blockId]) } model Coupon { userPropertiesToUpdate Json code String @id @unique dateRedeemed DateTime? } model Webhook { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt url String? method String queryParams Json headers Json body String? typebotId String typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade) } model ClaimableCustomPlan { id String @id @default(cuid()) createdAt DateTime @default(now()) claimedAt DateTime? name String description String? price Int currency String workspaceId String @unique workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade) chatsLimit Int storageLimit Int seatsLimit Int isYearly Boolean @default(false) companyName String? vatType String? vatValue String? } model ChatSession { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt state Json isReplying Boolean? } model ThemeTemplate { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt name String theme Json workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade) workspaceId String } model BannedIp { id String @id @default(cuid()) createdAt DateTime @default(now()) ip String @unique responsibleTypebot Typebot @relation(fields: [responsibleTypebotId], references: [id], onDelete: Restrict) responsibleTypebotId String user User @relation(fields: [userId], references: [id], onDelete: Restrict) userId String } enum WorkspaceRole { ADMIN MEMBER GUEST } enum GraphNavigation { MOUSE TRACKPAD } enum Plan { FREE STARTER PRO LIFETIME OFFERED CUSTOM UNLIMITED } enum CollaborationType { READ WRITE FULL_ACCESS }