Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Revert "new migration"
Roman Pominov30b2455c755a
diff --git a/packages/prisma-client/prisma/migrations/20220909124449_add_builds/migration.sql b/packages/prisma-client/prisma/migrations/20220909124449_add_builds/migration.sqlnew file mode 100644index 0000000000..400ff3a365--- /dev/null+++ b/packages/prisma-client/prisma/migrations/20220909124449_add_builds/migration.sql@@ -0,0 +1,14 @@+-- CreateTable+CREATE TABLE "Build" (+ "id" TEXT NOT NULL,+ "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,+ "pages" TEXT NOT NULL,+ "isDev" BOOLEAN NOT NULL,+ "isProd" BOOLEAN NOT NULL,+ "projectId" TEXT NOT NULL,++ CONSTRAINT "Build_pkey" PRIMARY KEY ("id")+);++-- AddForeignKey+ALTER TABLE "Build" ADD CONSTRAINT "Build_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE RESTRICT ON UPDATE CASCADE;diff --git a/packages/prisma-client/prisma/migrations/20220913130446_initialize_builds/migration.ts b/packages/prisma-client/prisma/migrations/20220909124542_move_to_builds/migration.tssimilarity index 64%rename from packages/prisma-client/prisma/migrations/20220913130446_initialize_builds/migration.tsrename to packages/prisma-client/prisma/migrations/20220909124542_move_to_builds/migration.tsindex cd702a4423..2df896a683 100644--- a/packages/prisma-client/prisma/migrations/20220913130446_initialize_builds/migration.ts+++ b/packages/prisma-client/prisma/migrations/20220909124542_move_to_builds/migration.ts@@ -1,4 +1,4 @@-import { PrismaClient, type Project, type Tree } from "./client";+import { PrismaClient, Prisma } from "./client";import { v4 as uuid } from "uuid";import { z } from "zod";@@ -18,11 +18,6 @@ const PagesSchema = z.object({pages: z.array(PageSchema),});-const isInHistory = (project: Project, tree: Tree) =>- TreeHistorySchema.parse(JSON.parse(project.prodTreeIdHistory)).includes(- tree.id- );-export default () => {const client = new PrismaClient({// Uncomment to see the queries in console as the migration runs@@ -32,12 +27,16 @@ export default () => {const trees = await prisma.tree.findMany();const projects = await prisma.project.findMany();+ const builds: Prisma.BuildCreateManyInput[] = [];+for (const tree of trees) {const project = projects.find((project) =>project.devTreeId === tree.id ||project.prodTreeId === tree.id ||- isInHistory(project, tree)+ TreeHistorySchema.parse(+ JSON.parse(project.prodTreeIdHistory)+ ).includes(tree.id));if (project === undefined) {@@ -56,20 +55,14 @@ export default () => {pages: [],});- const build = await prisma.build.create({- data: {- pages: JSON.stringify(pages),- isCurrentProd: project.prodTreeId === tree.id,- projectId: isInHistory(project, tree) ? project.id : undefined,- },+ builds.push({+ pages: JSON.stringify(pages),+ isDev: project.devTreeId === tree.id,+ isProd: project.prodTreeId === tree.id,+ projectId: project.id,});-- if (project.devTreeId === tree.id) {- await prisma.project.update({- where: { id: project.id },- data: { devBuildId: build.id },- });- }}++ await prisma.build.createMany({ data: builds });});};diff --git a/packages/prisma-client/prisma/migrations/20220913130446_initialize_builds/schema.prisma b/packages/prisma-client/prisma/migrations/20220909124542_move_to_builds/schema.prismasimilarity index 60%rename from packages/prisma-client/prisma/migrations/20220913130446_initialize_builds/schema.prismarename to packages/prisma-client/prisma/migrations/20220909124542_move_to_builds/schema.prismaindex d822e82ee8..a9532b86b0 100644--- a/packages/prisma-client/prisma/migrations/20220913130446_initialize_builds/schema.prisma+++ b/packages/prisma-client/prisma/migrations/20220909124542_move_to_builds/schema.prisma@@ -1,5 +1,5 @@// DO NOT EDIT THIS FILE!-// This is a copy of your schema.prisma that corresponds to the state of the database+// This a copy of your schema.prisma that corresponds to the state of the database// when all migrations up until this one are applied.// It's used to generate a Prisma Client for the migration.@@ -28,16 +28,17 @@ enum Location {}model Asset {- id String @id @default(uuid())- project Project @relation(fields: [projectId], references: [id])- projectId String- format String?- size Int- name String- description String?- location Location- createdAt DateTime @default(now())- meta String @default("{}")+ id String @id @default(uuid())+ project Project @relation(fields: [projectId], references: [id])+ projectId String+ format String?+ size Int+ width Decimal?+ height Decimal?+ name String+ alt String?+ location Location+ createdAt DateTime @default(now())}model User {@@ -59,17 +60,9 @@ model Project {user User? @relation(fields: [userId], references: [id])userId String?assets Asset[]+ build Build[]- // Mutable dev build- // (Nullable temporarily)- devBuild Build? @relation(name: "devBuild", fields: [devBuildId], references: [id])- devBuildId String?-- // History of immutable published builds- // one of which has isCurrentProd=true- buildsHistory Build[] @relation(name: "buildsHistory")-- // To be deleted+ // tmpprodTreeId String? // exists when publisheddevTreeId StringprodTreeIdHistory String @default("[]")@@ -79,14 +72,10 @@ model Build {id String @id @default(uuid())createdAt DateTime @default(now())pages String-- // Used only for immutable published builds- project Project? @relation(name: "buildsHistory", fields: [projectId], references: [id])- projectId String?- isCurrentProd Boolean-- // This is not used. Prisma requires all relations to be defined on both sides.- devProject__ Project[] @relation(name: "devBuild")+ isDev Boolean // exctly one is true per project+ isProd Boolean // at most one is true per project (none if not published)+ project Project @relation(fields: [projectId], references: [id])+ projectId String}model Tree {diff --git a/packages/prisma-client/prisma/migrations/20220909131750_remove_legacy_project_fields/migration.sql b/packages/prisma-client/prisma/migrations/20220909131750_remove_legacy_project_fields/migration.sqlnew file mode 100644index 0000000000..24114df501--- /dev/null+++ b/packages/prisma-client/prisma/migrations/20220909131750_remove_legacy_project_fields/migration.sql@@ -0,0 +1,4 @@+-- AlterTable+ALTER TABLE "Project" DROP COLUMN "devTreeId",+DROP COLUMN "prodTreeId",+DROP COLUMN "prodTreeIdHistory";diff --git a/packages/prisma-client/prisma/migrations/20220913130338_add_builds/migration.sql b/packages/prisma-client/prisma/migrations/20220913130338_add_builds/migration.sqldeleted file mode 100644index 89ef499d60..0000000000--- a/packages/prisma-client/prisma/migrations/20220913130338_add_builds/migration.sql+++ /dev/null@@ -1,19 +0,0 @@--- AlterTable-ALTER TABLE "Project" ADD COLUMN "devBuildId" TEXT;---- CreateTable-CREATE TABLE "Build" (- "id" TEXT NOT NULL,- "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,- "pages" TEXT NOT NULL,- "projectId" TEXT,- "isCurrentProd" BOOLEAN NOT NULL,-- CONSTRAINT "Build_pkey" PRIMARY KEY ("id")-);---- AddForeignKey-ALTER TABLE "Project" ADD CONSTRAINT "Project_devBuildId_fkey" FOREIGN KEY ("devBuildId") REFERENCES "Build"("id") ON DELETE SET NULL ON UPDATE CASCADE;---- AddForeignKey-ALTER TABLE "Build" ADD CONSTRAINT "Build_projectId_fkey" FOREIGN KEY ("projectId") REFERENCES "Project"("id") ON DELETE SET NULL ON UPDATE CASCADE;diff --git a/packages/prisma-client/prisma/migrations/20220913132316_cleanup_builds/migration.sql b/packages/prisma-client/prisma/migrations/20220913132316_cleanup_builds/migration.sqldeleted file mode 100644index e71f3a5014..0000000000--- a/packages/prisma-client/prisma/migrations/20220913132316_cleanup_builds/migration.sql+++ /dev/null@@ -1,11 +0,0 @@--- DropForeignKey-ALTER TABLE "Project" DROP CONSTRAINT "Project_devBuildId_fkey";---- AlterTable-ALTER TABLE "Project" DROP COLUMN "devTreeId",-DROP COLUMN "prodTreeId",-DROP COLUMN "prodTreeIdHistory",-ALTER COLUMN "devBuildId" SET NOT NULL;---- AddForeignKey-ALTER TABLE "Project" ADD CONSTRAINT "Project_devBuildId_fkey" FOREIGN KEY ("devBuildId") REFERENCES "Build"("id") ON DELETE RESTRICT ON UPDATE CASCADE;diff --git a/packages/prisma-client/prisma/schema.prisma b/packages/prisma-client/prisma/schema.prismaindex afe4a0fabb..3933ee3032 100644--- a/packages/prisma-client/prisma/schema.prisma+++ b/packages/prisma-client/prisma/schema.prisma@@ -54,28 +54,17 @@ model Project {user User? @relation(fields: [userId], references: [id])userId String?assets Asset[]-- // Mutable dev build- devBuild Build @relation(name: "devBuild", fields: [devBuildId], references: [id])- devBuildId String-- // History of immutable published builds- // one of which has isCurrentProd=true- buildsHistory Build[] @relation(name: "buildsHistory")+ build Build[]}model Build {id String @id @default(uuid())createdAt DateTime @default(now())pages String-- // Used only for immutable published builds- project Project? @relation(name: "buildsHistory", fields: [projectId], references: [id])- projectId String?- isCurrentProd Boolean @default(false)-- // This is not used. Prisma requires all relations to be defined on both sides.- devProject__ Project[] @relation(name: "devBuild")+ isDev Boolean // exctly one is true per project+ isProd Boolean // at most one is true per project (none if not published)+ project Project @relation(fields: [projectId], references: [id])+ projectId String}model Tree {