From d435a0db5a2a6f1a7b44f3bd1eb59498d6f731e1 Mon Sep 17 00:00:00 2001 From: Denis Bykhov Date: Wed, 6 Nov 2024 13:01:37 +0500 Subject: [PATCH] Fix force move tool (#7110) Signed-off-by: Denis Bykhov --- dev/tool/src/db.ts | 4 +++- dev/tool/src/index.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dev/tool/src/db.ts b/dev/tool/src/db.ts index 9edff48cfc..a26c4160fb 100644 --- a/dev/tool/src/db.ts +++ b/dev/tool/src/db.ts @@ -118,7 +118,9 @@ async function moveWorkspace ( } if (toRemove.length > 0) { await retryTxn(pgClient, async (client) => { - await client`DELETE FROM ${client(translateDomain(domain))} WHERE "workspaceId" = ${ws.workspace} AND _id IN (${client(toRemove)})` + await client.unsafe( + `DELETE FROM ${translateDomain(domain)} WHERE "workspaceId" = '${ws.workspace}' AND _id IN (${toRemove.map((c) => `'${c}'`).join(', ')})` + ) }) } if (docs.length === 0) break diff --git a/dev/tool/src/index.ts b/dev/tool/src/index.ts index 3c7d991517..762eb4ee9e 100644 --- a/dev/tool/src/index.ts +++ b/dev/tool/src/index.ts @@ -1687,7 +1687,7 @@ export function devTool ( if (workspaceInfo === null) { throw new Error(`workspace ${workspace} not found`) } - if (workspaceInfo.region === region) { + if (workspaceInfo.region === region && !cmd.force) { throw new Error(`workspace ${workspace} is already migrated`) } await moveWorkspaceFromMongoToPG(