From f063d7e2d510f018d4fc8c8a817dfb2f32aeae32 Mon Sep 17 00:00:00 2001 From: Ivan Starkov Date: Thu, 2 Feb 2023 15:34:44 +0400 Subject: [PATCH] Fix build create (#923) ## Description 1. What is this PR about (link the issue and add a short description) ## Steps for reproduction 1. click button 2. expect xyz ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [ ] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [ ] tested locally and on preview environment (preview dev login: 5de6) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio-designer/blob/main/apps/designer/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env.example` and the `designer/env-check.js` if mandatory --- packages/project/src/db/build.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/project/src/db/build.ts b/packages/project/src/db/build.ts index f8c3ff4705..2599234763 100644 --- a/packages/project/src/db/build.ts +++ b/packages/project/src/db/build.ts @@ -258,6 +258,13 @@ export async function create( ? (await db.breakpoints.load(sourceBuild.id)).values : db.breakpoints.createValues(); + if (env === "prod") { + await client.build.updateMany({ + where: { projectId: projectId, isProd: true }, + data: { isProd: false }, + }); + } + const build = await client.build.create({ data: { projectId, @@ -274,13 +281,6 @@ export async function create( ? await createPages({ projectId, buildId: build.id }, client) : await clonePages(sourceBuild.pages, client); - if (env === "prod") { - await client.build.updateMany({ - where: { projectId: projectId, isProd: true }, - data: { isProd: false }, - }); - } - await client.build.update({ where: { id: build.id,