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 String[] graphNavigation GraphNavigation? accounts Account[] apiTokens ApiToken[] CollaboratorsOnTypebots CollaboratorsOnTypebots[] workspaces MemberInWorkspace[] sessions Session[] } model ApiToken { id String @id @default(cuid()) token String @unique name String ownerId String lastUsedAt DateTime @default(now()) createdAt DateTime @default(now()) owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade) } model Workspace { id String @id @default(cuid()) name String icon String? createdAt DateTime @default(now()) 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? } model MemberInWorkspace { 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()) 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()) createdAt DateTime @default(now()) updatedAt DateTime @default(now()) @updatedAt icon String? name String publishedTypebotId String? folderId String? groups Json variables Json[] edges Json theme Json 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) } model Invitation { createdAt DateTime @default(now()) email String typebotId String type CollaborationType typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade) @@unique([email, typebotId]) } model CollaboratorsOnTypebots { 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()) 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()) updatedAt DateTime @default(now()) @updatedAt 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[] } 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()) 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([resultId]) } model Coupon { userPropertiesToUpdate Json code String @id @unique dateRedeemed DateTime? } model Webhook { id String @id @default(cuid()) url String? method String queryParams Json[] headers Json[] body String? typebotId String typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade) } enum WorkspaceRole { ADMIN MEMBER GUEST } enum GraphNavigation { MOUSE TRACKPAD } enum Plan { FREE STARTER PRO LIFETIME OFFERED } enum CollaborationType { READ WRITE FULL_ACCESS }