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

199 lines
5.6 KiB
Plaintext
Raw Normal View History

2021-11-29 15:19:07 +01:00
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
2021-12-06 15:48:50 +01:00
provider = "prisma-client-js"
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?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
oauth_token_secret String?
oauth_token String?
2021-11-29 15:19:07 +01:00
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 {
2022-02-24 11:13:19 +01:00
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
typebots Typebot[]
folders DashboardFolder[]
plan Plan @default(FREE)
stripeId String? @unique
credentials Credentials[]
customDomains CustomDomain[]
apiToken String?
CollaboratorsOnTypebots CollaboratorsOnTypebots[]
2022-02-18 14:57:10 +01:00
}
model CustomDomain {
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
name String @unique
}
model Credentials {
id String @id @default(cuid())
ownerId String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
data String // Encrypted data
name String
type String
iv String
@@unique([name, type, ownerId])
}
2021-12-06 15:48:50 +01:00
enum Plan {
FREE
PRO
2021-12-27 15:59:32 +01:00
LIFETIME
OFFERED
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
2021-12-06 15:48:50 +01:00
name String
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
ownerId String
parentFolderId String?
parentFolder DashboardFolder? @relation("ParentChild", fields: [parentFolderId], references: [id])
childrenFolder DashboardFolder[] @relation("ParentChild")
typebots Typebot[]
2022-02-21 06:57:44 +01:00
@@unique([id, ownerId])
2021-12-06 15:48:50 +01:00
}
model Typebot {
2022-02-24 11:13:19 +01:00
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
2021-12-06 15:48:50 +01:00
name String
ownerId String
2022-02-24 11:13:19 +01:00
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
2021-12-06 15:48:50 +01:00
publishedTypebotId String?
publishedTypebot PublicTypebot?
results Result[]
folderId String?
2022-02-24 11:13:19 +01:00
folder DashboardFolder? @relation(fields: [folderId], references: [id])
blocks Json[]
variables Json[]
edges Json[]
2021-12-23 09:37:42 +01:00
theme Json
2021-12-23 13:49:24 +01:00
settings Json
2022-02-24 11:13:19 +01:00
publicId String? @unique
customDomain String? @unique
collaborators CollaboratorsOnTypebots[]
invitations Invitation[]
2022-02-21 06:57:44 +01:00
@@unique([id, ownerId])
2021-12-06 15:48:50 +01:00
}
2022-02-24 11:13:19 +01:00
model Invitation {
email String
typebotId String
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
type CollaborationType
@@unique([email, typebotId])
}
model CollaboratorsOnTypebots {
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
typebotId String
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
type CollaborationType
@@unique([userId, typebotId])
}
enum CollaborationType {
READ
WRITE
}
2021-12-06 15:48:50 +01:00
model PublicTypebot {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
typebotId String @unique
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
2022-02-18 14:57:10 +01:00
name String
blocks Json[]
variables Json[]
edges Json[]
theme Json
settings Json
publicId String? @unique
customDomain String? @unique
2021-12-06 15:48:50 +01:00
}
model Result {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @default(now()) @updatedAt
typebotId String
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
answers Answer[]
prefilledVariables Json[]
isCompleted Boolean
2021-12-06 15:48:50 +01:00
}
2021-12-30 10:24:16 +01:00
model Answer {
createdAt DateTime @default(now())
resultId String
result Result @relation(fields: [resultId], references: [id], onDelete: Cascade)
stepId String
blockId String
variableId String?
content String
2021-12-30 10:24:16 +01:00
@@unique([resultId, blockId, stepId])
}
model Coupon {
userPropertiesToUpdate Json
code String @id @unique
dateRedeemed DateTime?
}