2
0
Files
bot/packages/prisma/mysql/schema.prisma

434 lines
14 KiB
Plaintext
Raw Normal View History

2022-08-08 08:21:36 +02:00
generator client {
provider = "prisma-client-js"
previewFeatures = ["metrics"]
2022-08-08 08:21:36 +02:00
}
2021-11-29 15:19:07 +01:00
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
2021-11-29 15:19:07 +01:00
}
model Account {
2021-12-06 15:48:50 +01:00
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String? @db.Text
access_token String? @db.Text
2021-12-06 15:48:50 +01:00
expires_at Int?
token_type String?
scope String?
id_token String? @db.Text
2021-12-06 15:48:50 +01:00
session_state String?
oauth_token_secret String?
oauth_token String?
2021-11-29 15:19:07 +01:00
refresh_token_expires_in Int?
2022-08-08 08:21:36 +02:00
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2021-11-29 15:19:07 +01:00
@@unique([provider, providerAccountId])
@@index([userId])
2021-11-29 15:19:07 +01:00
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@index([userId])
2021-11-29 15:19:07 +01:00
}
model User {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
lastActivityAt DateTime @default(now())
name String? @db.VarChar(255)
email String? @unique
emailVerified DateTime?
image String? @db.VarChar(1000)
company String?
onboardingCategories Json
referral String?
graphNavigation GraphNavigation?
preferredAppAppearance String?
accounts Account[]
apiTokens ApiToken[]
CollaboratorsOnTypebots CollaboratorsOnTypebots[]
workspaces MemberInWorkspace[]
sessions Session[]
bannedIps BannedIp[]
displayedInAppNotifications Json?
2022-05-13 15:22:44 -07:00
}
2022-06-03 13:20:19 +02:00
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)
@@index([ownerId])
2022-06-03 13:20:19 +02:00
}
2022-05-13 15:22:44 -07:00
model Workspace {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
name String @db.VarChar(255)
icon String? @db.VarChar(1000)
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?
2022-11-29 10:02:40 +01:00
claimableCustomPlan ClaimableCustomPlan?
customChatsLimit Int?
customStorageLimit Int?
customSeatsLimit Int?
isQuarantined Boolean @default(false)
isSuspended Boolean @default(false)
isPastDue Boolean @default(false)
isVerified Boolean?
themeTemplates ThemeTemplate[]
2022-05-13 15:22:44 -07:00
}
model MemberInWorkspace {
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2022-05-13 15:22:44 -07:00
userId String
workspaceId String
role WorkspaceRole
2022-08-08 08:21:36 +02:00
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
2022-05-13 15:22:44 -07:00
@@unique([userId, workspaceId])
@@index([workspaceId])
2022-05-13 15:22:44 -07:00
}
model WorkspaceInvitation {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2022-05-13 15:22:44 -07:00
email String
workspaceId String
type WorkspaceRole
2022-08-08 08:21:36 +02:00
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
@@index([workspaceId])
2022-02-18 14:57:10 +01:00
}
model CustomDomain {
name String @id @db.VarChar(255)
createdAt DateTime @default(now())
workspaceId String
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
@@index([workspaceId])
}
model Credentials {
id String @id @default(cuid())
createdAt DateTime @default(now())
workspaceId String
data String @db.Text
2022-05-13 15:22:44 -07:00
name String
type String
iv String
2022-08-08 08:21:36 +02:00
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
@@index([workspaceId])
2021-11-29 15:19:07 +01:00
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
2021-12-06 15:48:50 +01:00
}
model DashboardFolder {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
name String @db.VarChar(255)
2021-12-06 15:48:50 +01:00
parentFolderId String?
2022-08-08 08:21:36 +02:00
workspaceId String
parentFolder DashboardFolder? @relation("ParentChild", fields: [parentFolderId], references: [id], onDelete: NoAction, onUpdate: NoAction)
2022-08-08 08:21:36 +02:00
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
2021-12-06 15:48:50 +01:00
childrenFolder DashboardFolder[] @relation("ParentChild")
typebots Typebot[]
@@index([workspaceId])
@@index([parentFolderId])
2021-12-06 15:48:50 +01:00
}
model Typebot {
id String @id @default(cuid())
version String? @db.VarChar(10)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
icon String? @db.Text()
name String @db.VarChar(255)
folderId String?
groups Json
events Json?
variables Json
edges Json
theme Json
selectedThemeTemplateId String?
settings Json
publicId String? @unique
customDomain String? @unique
2022-08-08 08:21:36 +02:00
workspaceId String
resultsTablePreferences Json?
folder DashboardFolder? @relation(fields: [folderId], references: [id])
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
collaborators CollaboratorsOnTypebots[]
invitations Invitation[]
2022-08-08 08:21:36 +02:00
publishedTypebot PublicTypebot?
results Result[]
webhooks Webhook[]
isArchived Boolean @default(false)
isClosed Boolean @default(false)
whatsAppCredentialsId String?
riskLevel Int?
bannedIps BannedIp[]
2022-12-06 19:11:11 +01:00
@@index([workspaceId])
@@index([folderId])
2023-02-11 19:04:54 +01:00
@@index([isArchived, createdAt(sort: Desc)])
2021-12-06 15:48:50 +01:00
}
2022-02-24 11:13:19 +01:00
model Invitation {
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2022-02-24 11:13:19 +01:00
email String
typebotId String
type CollaborationType
2022-08-08 08:21:36 +02:00
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
2022-02-24 11:13:19 +01:00
@@unique([email, typebotId])
@@index([typebotId])
2022-02-24 11:13:19 +01:00
}
model CollaboratorsOnTypebots {
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2022-02-24 11:13:19 +01:00
userId String
typebotId String
type CollaborationType
2022-08-08 08:21:36 +02:00
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
2022-02-24 11:13:19 +01:00
@@unique([userId, typebotId])
@@index([typebotId])
2022-02-24 11:13:19 +01:00
}
2021-12-06 15:48:50 +01:00
model PublicTypebot {
id String @id @default(cuid())
version String? @db.VarChar(10)
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
typebotId String @unique
groups Json
events Json?
variables Json
edges Json
theme Json
settings Json
2022-08-08 08:21:36 +02:00
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
2021-12-06 15:48:50 +01:00
}
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[]
logs Log[]
edges VisitedEdge[]
setVariableHistory SetVariableHistoryItem[]
answersV2 AnswerV2[]
@@index([typebotId, isArchived, hasStarted, createdAt(sort: Desc)])
@@index([typebotId, isArchived, isCompleted])
2022-03-01 11:40:22 +01:00
}
model SetVariableHistoryItem {
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
resultId String
index Int
variableId String
blockId String
value Json // string or list of strings
@@unique([resultId, index])
}
model VisitedEdge {
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
resultId String
edgeId String
index Int
@@unique([resultId, index])
}
2022-03-01 11:40:22 +01:00
model Log {
id String @id @default(cuid())
createdAt DateTime @default(now())
2022-03-01 11:40:22 +01:00
resultId String
status String
description String @db.Text
details String? @db.Text
2022-08-08 08:21:36 +02:00
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
@@index([resultId])
2021-12-06 15:48:50 +01:00
}
2021-12-30 10:24:16 +01:00
// TODO: gradually remove variableId and groupId
2021-12-30 10:24:16 +01:00
model Answer {
createdAt DateTime @default(now()) @updatedAt
resultId String
blockId String
groupId String
variableId String?
content String @db.Text
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
2021-12-30 10:24:16 +01:00
2022-06-11 07:27:38 +02:00
@@unique([resultId, blockId, groupId])
}
model AnswerV2 {
id Int @id @default(autoincrement())
createdAt DateTime @default(now())
blockId String
content String @db.Text
attachedFileUrls Json?
resultId String
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
@@index([resultId])
@@index([blockId])
2021-12-30 10:24:16 +01:00
}
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? @db.VarChar(2000)
method String
queryParams Json
headers Json
body String? @db.Text
typebotId String
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
@@index([typebotId])
}
2022-08-08 08:21:36 +02:00
model ClaimableCustomPlan {
2022-11-29 10:02:40 +01:00
id String @id @default(cuid())
createdAt DateTime @default(now())
claimedAt DateTime?
name String
description String?
price Int
currency String
2022-11-29 10:02:40 +01:00
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?
}
2022-11-29 10:02:40 +01:00
model ChatSession {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
state Json
isReplying Boolean?
2022-11-29 10:02:40 +01:00
}
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
@@index([workspaceId])
}
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
@@index([responsibleTypebotId])
@@index([userId])
}
2022-08-08 08:21:36 +02:00
enum WorkspaceRole {
ADMIN
MEMBER
GUEST
}
enum GraphNavigation {
MOUSE
TRACKPAD
}
enum Plan {
FREE
STARTER
2022-08-08 08:21:36 +02:00
PRO
LIFETIME
OFFERED
CUSTOM
UNLIMITED
2022-08-08 08:21:36 +02:00
}
enum CollaborationType {
READ
WRITE
FULL_ACCESS
}