From 966bbedfa452324575711e336ec5a9a2875f91c4 Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 16:42:39 +0300 Subject: [PATCH 01/12] remove accidental import --- .../migrations/20220912142938_assets-meta-data/migration.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts index 15ad7112f7..6b71bb992c 100644 --- a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts +++ b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts @@ -1,4 +1,3 @@ -import { assert } from "console"; import { PrismaClient } from "./client"; // NOTE ON IMPORTS: From 63b6b2bedd0b12e98c7122b3ad74dac3514e261a Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 16:50:10 +0300 Subject: [PATCH 02/12] tmp make ci:migrate to resolve migration --- apps/designer/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/designer/package.json b/apps/designer/package.json index d0eaafb304..2d18b29524 100644 --- a/apps/designer/package.json +++ b/apps/designer/package.json @@ -14,7 +14,7 @@ "prettier": "prettier \"*.{js,md,json,ts}\" \"{docs,app}/**/*.{js,md,json,ts}\"", "storybook:run": "start-storybook -p 6006", "storybook:build": "build-storybook", - "ci:migrate": "migrations migrate --force" + "ci:migrate": "migrations resolve rolled-back 20220912142938_assets-meta-data --force && migrations migrate --force" }, "dependencies": { "@lexical/react": "^0.3.5", From 4f80f28837f6f9486ecd73d0963694bd98c875f5 Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 17:11:58 +0300 Subject: [PATCH 03/12] trying to see the error object --- .../migration.ts | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts index 6b71bb992c..60735d29e6 100644 --- a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts +++ b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts @@ -1,4 +1,5 @@ import { PrismaClient } from "./client"; +import { inspect } from "util"; // NOTE ON IMPORTS: // @@ -10,23 +11,32 @@ import { PrismaClient } from "./client"; // It's better to copy it to the migration directory. export default () => { - const client = new PrismaClient(); - return client.$transaction(async (prisma) => { - const previousAssets = await prisma.asset.findMany(); - const update = previousAssets.map((asset) => { - return { - id: asset.id, - description: asset.alt, - meta: JSON.stringify({ - width: Number(asset.width), - height: Number(asset.height), - }), - }; + try { + const client = new PrismaClient(); + + return client.$transaction(async (prisma) => { + const previousAssets = await prisma.asset.findMany(); + const update = previousAssets.map((asset) => { + return { + id: asset.id, + description: asset.alt, + meta: JSON.stringify({ + width: Number(asset.width), + height: Number(asset.height), + }), + }; + }); + await Promise.all( + update.map(({ id, ...data }) => + prisma.asset.update({ where: { id }, data }) + ) + ); }); - await Promise.all( - update.map(({ id, ...data }) => - prisma.asset.update({ where: { id }, data }) - ) - ); - }); + } catch (error) { + if (error instanceof Error) { + throw error; + } else { + throw new Error(inspect(error)); + } + } }; From 4d4b5f9451ab9a856cde5ed21cf09cc87f080e26 Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 17:25:49 +0300 Subject: [PATCH 04/12] fix error processing --- .../prisma-client/migrations-cli/commands.ts | 10 ++++- .../migration.ts | 45 ++++++++----------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/packages/prisma-client/migrations-cli/commands.ts b/packages/prisma-client/migrations-cli/commands.ts index 32c8a7868d..d6f8099406 100644 --- a/packages/prisma-client/migrations-cli/commands.ts +++ b/packages/prisma-client/migrations-cli/commands.ts @@ -2,6 +2,7 @@ import fs from "node:fs"; import path from "node:path"; import { FileLocker, MigrationMeta } from "umzug"; import confirm from "@inquirer/confirm"; +import { inspect } from "node:util"; import * as prismaMigrations from "./prisma-migrations"; import { umzug } from "./umzug"; import * as logger from "./logger"; @@ -256,13 +257,18 @@ If you're sure no other process is running, please delete the lockfile: try { await umzug.up(); } catch (err) { + const originalError: unknown = err.cause || err; + const originalErrorString = + (originalError instanceof Error && originalError.stack) || + inspect(originalError); + logger.error(""); - logger.error(err.stack); + logger.error(originalErrorString); logger.error(""); const migrationName = (err.migration || undefined)?.name; if (typeof migrationName === "string") { - prismaMigrations.setFailed(migrationName, err.stack); + prismaMigrations.setFailed(migrationName, originalErrorString); } process.exitCode = 1; diff --git a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts index 60735d29e6..6cf76425ce 100644 --- a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts +++ b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts @@ -1,5 +1,4 @@ import { PrismaClient } from "./client"; -import { inspect } from "util"; // NOTE ON IMPORTS: // @@ -11,32 +10,24 @@ import { inspect } from "util"; // It's better to copy it to the migration directory. export default () => { - try { - const client = new PrismaClient(); + const client = new PrismaClient(); - return client.$transaction(async (prisma) => { - const previousAssets = await prisma.asset.findMany(); - const update = previousAssets.map((asset) => { - return { - id: asset.id, - description: asset.alt, - meta: JSON.stringify({ - width: Number(asset.width), - height: Number(asset.height), - }), - }; - }); - await Promise.all( - update.map(({ id, ...data }) => - prisma.asset.update({ where: { id }, data }) - ) - ); + return client.$transaction(async (prisma) => { + const previousAssets = await prisma.asset.findMany(); + const update = previousAssets.map((asset) => { + return { + id: asset.id, + description: asset.alt, + meta: JSON.stringify({ + width: Number(asset.width), + height: Number(asset.height), + }), + }; }); - } catch (error) { - if (error instanceof Error) { - throw error; - } else { - throw new Error(inspect(error)); - } - } + await Promise.all( + update.map(({ id, ...data }) => + prisma.asset.update({ where: { id }, data }) + ) + ); + }); }; From 99df39cbb18944c9e72be0f45db99d3c6877a2f4 Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 17:33:26 +0300 Subject: [PATCH 05/12] change timeout --- .../migration.ts | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts index 6cf76425ce..0652f5fe03 100644 --- a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts +++ b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts @@ -12,22 +12,25 @@ import { PrismaClient } from "./client"; export default () => { const client = new PrismaClient(); - return client.$transaction(async (prisma) => { - const previousAssets = await prisma.asset.findMany(); - const update = previousAssets.map((asset) => { - return { - id: asset.id, - description: asset.alt, - meta: JSON.stringify({ - width: Number(asset.width), - height: Number(asset.height), - }), - }; - }); - await Promise.all( - update.map(({ id, ...data }) => - prisma.asset.update({ where: { id }, data }) - ) - ); - }); + return client.$transaction( + async (prisma) => { + const previousAssets = await prisma.asset.findMany(); + const update = previousAssets.map((asset) => { + return { + id: asset.id, + description: asset.alt, + meta: JSON.stringify({ + width: Number(asset.width), + height: Number(asset.height), + }), + }; + }); + await Promise.all( + update.map(({ id, ...data }) => + prisma.asset.update({ where: { id }, data }) + ) + ); + }, + { timeout: 1000 * 60 * 5 } + ); }; From 1f66d29db7b003143a53f01dac23fc31bea523b6 Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 17:54:16 +0300 Subject: [PATCH 06/12] add trobleshooting guide --- .../migrations-cli/TROUBLESHOOTING.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 packages/prisma-client/migrations-cli/TROUBLESHOOTING.md diff --git a/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md new file mode 100644 index 0000000000..46a50de3f8 --- /dev/null +++ b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md @@ -0,0 +1,40 @@ +## A migration failed in PREVIEW, how do I fix the PREVIEW database + +1. Open a new PR where you'll do the fix +1. Go to https://vercel.com/webstudio-is/webstudio-designer/settings/environment-variables +1. Set APPLY_MIGRATIONS to "true" for you PR's branch +1. Fix the failed migration code +1. Temporarily change `ci:migrate` script to run `resolve` before applying migrations: `"ci:migrate": "migrations resolve rolled-back --force && migrations migrate --force"` +1. Commit the changes and check Vercel logs to see if the migration is applied +1. Change `ci:migrate` script back to normal +1. Merge the PR +1. Remove APPLY_MIGRATIONS from Vercel settings for your branch + +## Transacation failed with a error "Transaction API error: Transaction already closed: Could not perform operation." + +Most likely reason Prisma has thrown this error is because transaction has timed out. If that's the case you have following options: + +1. Increase the timeout: + +```js +prisma.$transaction( + async (tx) => { + // Code running in a transaction... + }, + { + timeout: 1000 * 60, // in milliseconds, default 5000 + } +); +``` + +2. Do not wrap the migration body into a transaction: + +```js +export default async () => { + const prisma = new PrismaClient(); + // use `prisma` here without wrapping it into a transaction +}; +``` + +Note that in this case if the migration fails again, it will be harder to fix the database, +because the migration can end up half-way applied. From b7914b96c45fbe566088496bbbbb5471452e947d Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 17:56:38 +0300 Subject: [PATCH 07/12] add timeout to other migrations --- .../migrations-cli/TROUBLESHOOTING.md | 2 +- .../20220909124542_builds-data/migration.ts | 77 ++++++++++--------- .../migration.ts | 2 +- .../migration.ts | 55 ++++++------- .../prisma/migrations/template.txt | 2 +- 5 files changed, 72 insertions(+), 66 deletions(-) diff --git a/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md index 46a50de3f8..b138d0b524 100644 --- a/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md +++ b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md @@ -22,7 +22,7 @@ prisma.$transaction( // Code running in a transaction... }, { - timeout: 1000 * 60, // in milliseconds, default 5000 + timeout: 1000 * 60 * 2, // in milliseconds, default 5000 } ); ``` diff --git a/packages/prisma-client/prisma/migrations/20220909124542_builds-data/migration.ts b/packages/prisma-client/prisma/migrations/20220909124542_builds-data/migration.ts index 2df896a683..382918738f 100644 --- a/packages/prisma-client/prisma/migrations/20220909124542_builds-data/migration.ts +++ b/packages/prisma-client/prisma/migrations/20220909124542_builds-data/migration.ts @@ -23,46 +23,49 @@ export default () => { // Uncomment to see the queries in console as the migration runs // log: ["query", "info", "warn", "error"], }); - return client.$transaction(async (prisma) => { - const trees = await prisma.tree.findMany(); - const projects = await prisma.project.findMany(); + return client.$transaction( + async (prisma) => { + const trees = await prisma.tree.findMany(); + const projects = await prisma.project.findMany(); - const builds: Prisma.BuildCreateManyInput[] = []; + const builds: Prisma.BuildCreateManyInput[] = []; - for (const tree of trees) { - const project = projects.find( - (project) => - project.devTreeId === tree.id || - project.prodTreeId === tree.id || - TreeHistorySchema.parse( - JSON.parse(project.prodTreeIdHistory) - ).includes(tree.id) - ); + for (const tree of trees) { + const project = projects.find( + (project) => + project.devTreeId === tree.id || + project.prodTreeId === tree.id || + TreeHistorySchema.parse( + JSON.parse(project.prodTreeIdHistory) + ).includes(tree.id) + ); - if (project === undefined) { - continue; + if (project === undefined) { + continue; + } + + const pages = PagesSchema.parse({ + homePage: { + id: uuid(), + name: "Home", + path: "", + title: "Home", + meta: {}, + treeId: tree.id, + }, + pages: [], + }); + + builds.push({ + pages: JSON.stringify(pages), + isDev: project.devTreeId === tree.id, + isProd: project.prodTreeId === tree.id, + projectId: project.id, + }); } - const pages = PagesSchema.parse({ - homePage: { - id: uuid(), - name: "Home", - path: "", - title: "Home", - meta: {}, - treeId: tree.id, - }, - pages: [], - }); - - builds.push({ - pages: JSON.stringify(pages), - isDev: project.devTreeId === tree.id, - isProd: project.prodTreeId === tree.id, - projectId: project.id, - }); - } - - await prisma.build.createMany({ data: builds }); - }); + await prisma.build.createMany({ data: builds }); + }, + { timeout: 1000 * 60 } + ); }; diff --git a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts index 0652f5fe03..43b7920027 100644 --- a/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts +++ b/packages/prisma-client/prisma/migrations/20220912142938_assets-meta-data/migration.ts @@ -31,6 +31,6 @@ export default () => { ) ); }, - { timeout: 1000 * 60 * 5 } + { timeout: 1000 * 60 } ); }; diff --git a/packages/prisma-client/prisma/migrations/20220915144008_breakpoints-build_data/migration.ts b/packages/prisma-client/prisma/migrations/20220915144008_breakpoints-build_data/migration.ts index 0a7eefa820..e6f38ae448 100644 --- a/packages/prisma-client/prisma/migrations/20220915144008_breakpoints-build_data/migration.ts +++ b/packages/prisma-client/prisma/migrations/20220915144008_breakpoints-build_data/migration.ts @@ -20,34 +20,37 @@ export default () => { // Uncomment to see the queries in console as the migration runs // log: ["query", "info", "warn", "error"], }); - return client.$transaction(async (prisma) => { - const builds = await prisma.build.findMany(); - const breakpoints = await prisma.breakpoints.findMany(); + return client.$transaction( + async (prisma) => { + const builds = await prisma.build.findMany(); + const breakpoints = await prisma.breakpoints.findMany(); - const buildsParsed = builds.map((build) => ({ - id: build.id, - pages: PagesSchema.parse(JSON.parse(build.pages)), - })); + const buildsParsed = builds.map((build) => ({ + id: build.id, + pages: PagesSchema.parse(JSON.parse(build.pages)), + })); - await Promise.all( - breakpoints.map((breakpoint) => { - const build = buildsParsed.find( - (build) => build.pages.homePage.treeId === breakpoint.treeId - ); - - if (build === undefined) { - throw new Error( - `Build not found for breakpoint ${breakpoint.treeId}` + await Promise.all( + breakpoints.map((breakpoint) => { + const build = buildsParsed.find( + (build) => build.pages.homePage.treeId === breakpoint.treeId ); - } - return prisma.breakpoints.update({ - where: { treeId: breakpoint.treeId }, - data: { - buildId: build.id, - }, - }); - }) - ); - }); + if (build === undefined) { + throw new Error( + `Build not found for breakpoint ${breakpoint.treeId}` + ); + } + + return prisma.breakpoints.update({ + where: { treeId: breakpoint.treeId }, + data: { + buildId: build.id, + }, + }); + }) + ); + }, + { timeout: 1000 * 60 } + ); }; diff --git a/packages/prisma-client/prisma/migrations/template.txt b/packages/prisma-client/prisma/migrations/template.txt index b63e297a0f..c330e9dabd 100644 --- a/packages/prisma-client/prisma/migrations/template.txt +++ b/packages/prisma-client/prisma/migrations/template.txt @@ -33,5 +33,5 @@ export default () => { // NOTE: // Don't do any schema modifications here like adding a column to a table! // If you need to change schema, edit schema.prisma and create a schema migration. - }); + }, { timeout: 1000 * 60 }); }; From 4bfb0032b1f0639daa6893e054d710e000e0c411 Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 18:00:52 +0300 Subject: [PATCH 08/12] update troubleshooting --- .../migrations-cli/TROUBLESHOOTING.md | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md index b138d0b524..4941657601 100644 --- a/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md +++ b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md @@ -12,19 +12,22 @@ ## Transacation failed with a error "Transaction API error: Transaction already closed: Could not perform operation." -Most likely reason Prisma has thrown this error is because transaction has timed out. If that's the case you have following options: +Most likely reason Prisma has thrown this error is because transaction has timed out. If that's the case, you have following options: 1. Increase the timeout: ```js -prisma.$transaction( - async (tx) => { - // Code running in a transaction... - }, - { - timeout: 1000 * 60 * 2, // in milliseconds, default 5000 - } -); +export default () => { + const client = new PrismaClient(); + return client.$transaction( + async (prisma) => { + // migration code... + }, + { + timeout: 1000 * 60 * 2, // in milliseconds, default 5000 + } + ); +}; ``` 2. Do not wrap the migration body into a transaction: From 2a7e390fb6ab7a6f6a1f125fe497eda83dfaeffd Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 18:02:14 +0300 Subject: [PATCH 09/12] rollback another migration --- apps/designer/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/designer/package.json b/apps/designer/package.json index 2d18b29524..9584e2a9aa 100644 --- a/apps/designer/package.json +++ b/apps/designer/package.json @@ -14,7 +14,7 @@ "prettier": "prettier \"*.{js,md,json,ts}\" \"{docs,app}/**/*.{js,md,json,ts}\"", "storybook:run": "start-storybook -p 6006", "storybook:build": "build-storybook", - "ci:migrate": "migrations resolve rolled-back 20220912142938_assets-meta-data --force && migrations migrate --force" + "ci:migrate": "migrations resolve rolled-back 20220915144008_breakpoints-build_data --force && migrations migrate --force" }, "dependencies": { "@lexical/react": "^0.3.5", From ad370bcdb3992e4b148c8c2f149716685c32099c Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 18:07:45 +0300 Subject: [PATCH 10/12] update troublechooting --- packages/prisma-client/migrations-cli/TROUBLESHOOTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md index 4941657601..024c3be2a2 100644 --- a/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md +++ b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md @@ -4,7 +4,8 @@ 1. Go to https://vercel.com/webstudio-is/webstudio-designer/settings/environment-variables 1. Set APPLY_MIGRATIONS to "true" for you PR's branch 1. Fix the failed migration code -1. Temporarily change `ci:migrate` script to run `resolve` before applying migrations: `"ci:migrate": "migrations resolve rolled-back --force && migrations migrate --force"` +1. Fix the database mannually if the migration have been applied half-way +1. Temporarily change `ci:migrate` script to run `resolve` before applying migrations: `"ci:migrate": "migrations resolve rolled-back --force && migrations migrate --force"`. Use `applied` instead of `rolled-back` if you manually applied the migration at previous step. 1. Commit the changes and check Vercel logs to see if the migration is applied 1. Change `ci:migrate` script back to normal 1. Merge the PR @@ -12,7 +13,8 @@ ## Transacation failed with a error "Transaction API error: Transaction already closed: Could not perform operation." -Most likely reason Prisma has thrown this error is because transaction has timed out. If that's the case, you have following options: +Most likely reason Prisma has thrown this error is because transaction has timed out. +If that's the case, you have the following options: 1. Increase the timeout: From 8ec40046072dbc03628c7535979cc00587f58dce Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 18:08:00 +0300 Subject: [PATCH 11/12] restore ci:migrate --- apps/designer/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/designer/package.json b/apps/designer/package.json index 9584e2a9aa..d0eaafb304 100644 --- a/apps/designer/package.json +++ b/apps/designer/package.json @@ -14,7 +14,7 @@ "prettier": "prettier \"*.{js,md,json,ts}\" \"{docs,app}/**/*.{js,md,json,ts}\"", "storybook:run": "start-storybook -p 6006", "storybook:build": "build-storybook", - "ci:migrate": "migrations resolve rolled-back 20220915144008_breakpoints-build_data --force && migrations migrate --force" + "ci:migrate": "migrations migrate --force" }, "dependencies": { "@lexical/react": "^0.3.5", From 57762cdea140854ae6cbaae8fd781c0b5675219e Mon Sep 17 00:00:00 2001 From: Roman Pominov Date: Thu, 15 Sep 2022 20:57:58 +0300 Subject: [PATCH 12/12] edit troubleshooting --- packages/prisma-client/migrations-cli/TROUBLESHOOTING.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md index 024c3be2a2..aaad796e53 100644 --- a/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md +++ b/packages/prisma-client/migrations-cli/TROUBLESHOOTING.md @@ -2,7 +2,7 @@ 1. Open a new PR where you'll do the fix 1. Go to https://vercel.com/webstudio-is/webstudio-designer/settings/environment-variables -1. Set APPLY_MIGRATIONS to "true" for you PR's branch +1. Set APPLY_MIGRATIONS to "true" for your PR's branch 1. Fix the failed migration code 1. Fix the database mannually if the migration have been applied half-way 1. Temporarily change `ci:migrate` script to run `resolve` before applying migrations: `"ci:migrate": "migrations resolve rolled-back --force && migrations migrate --force"`. Use `applied` instead of `rolled-back` if you manually applied the migration at previous step. @@ -16,7 +16,8 @@ Most likely reason Prisma has thrown this error is because transaction has timed out. If that's the case, you have the following options: -1. Increase the timeout: +1. Optimize your migration to make it faster +2. Increase the timeout: ```js export default () => { @@ -32,7 +33,7 @@ export default () => { }; ``` -2. Do not wrap the migration body into a transaction: +3. Do not wrap the migration body into a transaction: ```js export default async () => {