Add Dashboard
This commit is contained in:
@ -4,19 +4,14 @@
|
||||
"devDependencies": {
|
||||
"dotenv-cli": "^4.1.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prisma": "^3.5.0",
|
||||
"prisma": "latest",
|
||||
"ts-node": "^10.4.0",
|
||||
"typescript": "^4.5.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@prisma/client": "^3.5.0"
|
||||
"@prisma/client": "latest"
|
||||
},
|
||||
"scripts": {
|
||||
"prisma": "dotenv -e ../../.env prisma",
|
||||
"dev": "run-s migrate generate build",
|
||||
"build": "dotenv -e ../../.env tsc --build",
|
||||
"migrate": "dotenv -e ../../.env prisma migrate dev",
|
||||
"push": "dotenv -e ../../.env prisma db push",
|
||||
"generate": "dotenv -e ../../.env prisma generate"
|
||||
"prisma": "dotenv -e ../../.env prisma"
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,70 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "Plan" AS ENUM ('FREE', 'PRO');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "User" ADD COLUMN "plan" "Plan" NOT NULL DEFAULT E'FREE';
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "DashboardFolder" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"name" TEXT NOT NULL,
|
||||
"ownerId" TEXT NOT NULL,
|
||||
"parentFolderId" TEXT,
|
||||
|
||||
CONSTRAINT "DashboardFolder_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Typebot" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"name" TEXT NOT NULL,
|
||||
"ownerId" TEXT NOT NULL,
|
||||
"publishedTypebotId" TEXT,
|
||||
"folderId" TEXT,
|
||||
|
||||
CONSTRAINT "Typebot_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "PublicTypebot" (
|
||||
"id" TEXT NOT NULL,
|
||||
"typebotId" TEXT NOT NULL,
|
||||
"steps" JSONB[],
|
||||
"name" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "PublicTypebot_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "Result" (
|
||||
"id" TEXT NOT NULL,
|
||||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"typebotId" TEXT NOT NULL,
|
||||
|
||||
CONSTRAINT "Result_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "PublicTypebot_typebotId_key" ON "PublicTypebot"("typebotId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DashboardFolder" ADD CONSTRAINT "DashboardFolder_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "DashboardFolder" ADD CONSTRAINT "DashboardFolder_parentFolderId_fkey" FOREIGN KEY ("parentFolderId") REFERENCES "DashboardFolder"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Typebot" ADD CONSTRAINT "Typebot_ownerId_fkey" FOREIGN KEY ("ownerId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Typebot" ADD CONSTRAINT "Typebot_folderId_fkey" FOREIGN KEY ("folderId") REFERENCES "DashboardFolder"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "PublicTypebot" ADD CONSTRAINT "PublicTypebot_typebotId_fkey" FOREIGN KEY ("typebotId") REFERENCES "Typebot"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "Result" ADD CONSTRAINT "Result_typebotId_fkey" FOREIGN KEY ("typebotId") REFERENCES "Typebot"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
87
packages/prisma/prisma/schema.draft.prisma
Normal file
87
packages/prisma/prisma/schema.draft.prisma
Normal file
@ -0,0 +1,87 @@
|
||||
datasource db {
|
||||
url = env("DATABASE_URL")
|
||||
provider = "postgresql"
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id
|
||||
createdAt DateTime @default(now())
|
||||
email String @unique
|
||||
name String?
|
||||
avatarUrl String?
|
||||
redeemedCoupon Boolean?
|
||||
oAuthCredentials Json?
|
||||
referralId String?
|
||||
domains String[]
|
||||
onboarding_data Json?
|
||||
settings Json
|
||||
typebots Typebot[] @relation("Owner")
|
||||
sharedTypebots Typebot[] @relation("Collaborators")
|
||||
dashboardFolders DashboardFolder[]
|
||||
}
|
||||
|
||||
model DashboardFolder {
|
||||
id BigInt @id @default(autoincrement())
|
||||
createdAt DateTime @default(now())
|
||||
name String
|
||||
owner User @relation(fields: [ownerId], references: [id])
|
||||
ownerId String
|
||||
parentFolderId BigInt
|
||||
parentFolder DashboardFolder @relation("ParentChild", fields: [parentFolderId], references: [id])
|
||||
childrenFolder DashboardFolder[] @relation("ParentChild")
|
||||
}
|
||||
|
||||
model Typebot {
|
||||
id BigInt @id @default(autoincrement())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now())
|
||||
steps Json[]
|
||||
publishedTypebotId BigInt @unique
|
||||
publishedTypebot PublicTypebot @relation(fields: [publishedTypebotId], references: [id])
|
||||
connectors Json[]
|
||||
name String
|
||||
ownerId String
|
||||
owner User @relation("Owner", fields: [ownerId], references: [id])
|
||||
conditions Json
|
||||
startConditions Json
|
||||
theme Json
|
||||
settings Json
|
||||
collaborators User[] @relation("Collaborators")
|
||||
customDomains String[]
|
||||
shareSettings Json
|
||||
variables Json
|
||||
checkedConversionRules String[]
|
||||
results Result[]
|
||||
httpRequests Json[]
|
||||
credentials Json[]
|
||||
}
|
||||
|
||||
model PublicTypebot {
|
||||
id BigInt @id @default(autoincrement())
|
||||
typebot Typebot?
|
||||
steps Json[]
|
||||
name String
|
||||
conditions Json
|
||||
startConditions Json
|
||||
theme Json
|
||||
settings Json
|
||||
connectors Json
|
||||
customDomains String[]
|
||||
shareSettings Json
|
||||
variables Json
|
||||
}
|
||||
|
||||
model Result {
|
||||
id BigInt @id @default(autoincrement())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now())
|
||||
typebotId BigInt
|
||||
typebot Typebot @relation(fields: [typebotId], references: [id])
|
||||
variables Json[]
|
||||
isCompleted Boolean
|
||||
answers Json[]
|
||||
}
|
@ -4,24 +4,24 @@ datasource db {
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
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?
|
||||
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)
|
||||
@ -38,13 +38,21 @@ model Session {
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String? @unique
|
||||
email String? @unique
|
||||
emailVerified DateTime?
|
||||
image String?
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
typebots Typebot[]
|
||||
folders DashboardFolder[]
|
||||
plan Plan @default(FREE)
|
||||
}
|
||||
|
||||
enum Plan {
|
||||
FREE
|
||||
PRO
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
@ -53,4 +61,46 @@ model VerificationToken {
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
}
|
||||
}
|
||||
|
||||
model DashboardFolder {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
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[]
|
||||
}
|
||||
|
||||
model Typebot {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now())
|
||||
name String
|
||||
ownerId String
|
||||
owner User @relation(fields: [ownerId], references: [id], onDelete: Cascade)
|
||||
publishedTypebotId String?
|
||||
publishedTypebot PublicTypebot?
|
||||
results Result[]
|
||||
folderId String?
|
||||
folder DashboardFolder? @relation(fields: [folderId], references: [id])
|
||||
}
|
||||
|
||||
model PublicTypebot {
|
||||
id String @id @default(cuid())
|
||||
typebotId String @unique
|
||||
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
|
||||
steps Json[]
|
||||
name String
|
||||
}
|
||||
|
||||
model Result {
|
||||
id String @id @default(cuid())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @default(now())
|
||||
typebotId String
|
||||
typebot Typebot @relation(fields: [typebotId], references: [id], onDelete: Cascade)
|
||||
}
|
||||
|
Reference in New Issue
Block a user