generator client { provider = "prisma-client-js" } 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 graphNavigation GraphNavigation? preferredAppAppearance String? accounts Account[] apiTokens ApiToken[] CollaboratorsOnTypebots CollaboratorsOnTypebots[] workspaces MemberInWorkspace[] sessions Session[] } 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) 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 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) @@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 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) typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade) answers Answer[] logs Log[] @@index([typebotId, hasStarted, createdAt(sort: Desc)]) @@index([typebotId, isCompleted]) } 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 storageUsed Int? result Result @relation(fields: [resultId], references: [id], onDelete: Cascade) @@unique([resultId, blockId, groupId]) @@index([groupId]) @@index([storageUsed]) } 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 } model ChatSession { id String @id @default(cuid()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt state Json } 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 } enum WorkspaceRole { ADMIN MEMBER GUEST } enum GraphNavigation { MOUSE TRACKPAD } enum Plan { FREE STARTER PRO LIFETIME OFFERED CUSTOM UNLIMITED } enum CollaborationType { READ WRITE FULL_ACCESS }