Recreate all workspace indexes tool (#6946)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2024-10-17 02:56:32 +07:00
committed by GitHub
parent 78c1938e3e
commit 2ae1b6d4e0
2 changed files with 18 additions and 12 deletions
+1 -10
View File
@@ -98,24 +98,15 @@ export async function updateField (
}
}
export async function recreateElastic (
mongoUrl: string,
workspaceId: WorkspaceId,
transactorUrl: string
): Promise<void> {
export async function recreateElastic (mongoUrl: string, workspaceId: WorkspaceId): Promise<void> {
const client = getMongoClient(mongoUrl)
const _client = await client.getClient()
const connection = (await connect(transactorUrl, workspaceId, undefined, {
mode: 'backup'
})) as unknown as CoreClient & BackupClient
try {
const db = getWorkspaceMongoDB(_client, workspaceId)
await db
.collection(DOMAIN_DOC_INDEX_STATE)
.updateMany({ _class: core.class.DocIndexState }, { $set: { stages: {}, needIndex: true } })
await connection.sendForceClose()
} finally {
client.close()
await connection.close()
}
}