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
build: Make migration fast (#2597)
Ivan Starkov7373d38a32ca
diff --git a/fixtures/webstudio-remix-vercel/.webstudio/data.json b/fixtures/webstudio-remix-vercel/.webstudio/data.jsonindex 72444e67ff..13f4a181a3 100644--- a/fixtures/webstudio-remix-vercel/.webstudio/data.json+++ b/fixtures/webstudio-remix-vercel/.webstudio/data.json@@ -4,7 +4,7 @@"projectId": "cddc1d44-af37-4cb6-a430-d300cf6f932d","version": 222,"createdAt": "2023-11-03T13:22:34.879Z",- "updatedAt": "2023-11-09T09:26:06.133Z",+ "updatedAt": "2023-11-10T17:10:50.248Z","pages": {"meta": {"siteName": "KittyGuardedZone",diff --git a/fixtures/webstudio-remix-vercel/app/__generated__/[sitemap.xml].ts b/fixtures/webstudio-remix-vercel/app/__generated__/[sitemap.xml].tsindex d690702891..047c22ff6c 100644--- a/fixtures/webstudio-remix-vercel/app/__generated__/[sitemap.xml].ts+++ b/fixtures/webstudio-remix-vercel/app/__generated__/[sitemap.xml].ts@@ -2,19 +2,19 @@ export const sitemap = {pages: [{path: "",- lastModified: "2023-11-09T09:26:06.133Z",+ lastModified: "2023-11-10T17:10:50.248Z",},{path: "/_route_with_symbols_",- lastModified: "2023-11-09T09:26:06.133Z",+ lastModified: "2023-11-10T17:10:50.248Z",},{path: "/form",- lastModified: "2023-11-09T09:26:06.133Z",+ lastModified: "2023-11-10T17:10:50.248Z",},{path: "/heading-with-id",- lastModified: "2023-11-09T09:26:06.133Z",+ lastModified: "2023-11-10T17:10:50.248Z",},],};diff --git a/packages/prisma-client/prisma/migrations/20231108172804_prop_expression/migration.ts b/packages/prisma-client/prisma/migrations/20231108172804_prop_expression/migration.tsindex e1bb15b84c..9d7c47e117 100644--- a/packages/prisma-client/prisma/migrations/20231108172804_prop_expression/migration.ts+++ b/packages/prisma-client/prisma/migrations/20231108172804_prop_expression/migration.ts@@ -68,19 +68,55 @@ export default async () => {const chunkSize = 1000;let cursor: undefined | string = undefined;let hasNext = true;+while (hasNext) {+ console.log("CHUNK", cursor);+ console.time("read");++ const cursorOptions: {} = cursor+ ? {+ skip: 1, // Skip the cursor+ cursor: { id: cursor },+ }+ : {};+const builds = await prisma.build.findMany({+ select: {+ id: true,+ props: true,+ dataSources: true,+ },take: chunkSize,orderBy: {id: "asc",},- ...(cursor- ? {- skip: 1, // Skip the cursor- cursor: { id: cursor },- }- : null),+ where: {+ AND: [+ {+ OR: [+ {+ props: {+ not: "[]",+ },+ },+ {+ dataSources: {+ not: "[]",+ },+ },+ ],+ },+ {+ deployment: null,+ },+ ],+ },++ ...cursorOptions,});+ console.timeEnd("read");++ console.time("parse-change");cursor = builds.at(-1)?.id;hasNext = builds.length === chunkSize;const changedBuilds: typeof builds = [];@@ -142,14 +178,28 @@ export default async () => {console.info(`build ${buildId} cannot be converted`);}}- await Promise.all(- changedBuilds.map(({ id, props, dataSources }) =>- prisma.build.update({- where: { id },- data: { props, dataSources },- })- )+ console.timeEnd("parse-change");+ console.log("changedBuilds.length", changedBuilds.length);+ console.time("update");++ const sql = `+ UPDATE "Build"+ SET+ "props" = data."props",+ "dataSources" = data."dataSources"+ FROM unnest(ARRAY[$1], ARRAY[$2], ARRAY[$3]) as data(id, props, "dataSources")+ WHERE "Build"."id" = data."id"+ `;++ const res = await prisma.$executeRawUnsafe(+ sql,+ changedBuilds.map((changedBuild) => changedBuild.id),+ changedBuilds.map((changedBuild) => changedBuild.props),+ changedBuilds.map((changedBuild) => changedBuild.dataSources));++ console.timeEnd("update");+ console.log("res", res);}},{ timeout: 3600000 }