UBERF-7670: Per region moves (#7444)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2024-12-13 00:20:35 +07:00
committed by GitHub
parent 1eefb143cc
commit 7b497c93c1
35 changed files with 1597 additions and 463 deletions
+32 -2
View File
@@ -13,6 +13,36 @@
// limitations under the License.
//
export * from './storage'
export { getDBClient, convertDoc, createTables, retryTxn } from './utils'
import type { WorkspaceDestroyAdapter } from '@hcengineering/server-core'
import { domainSchemas } from './schemas'
import { getDBClient, retryTxn } from './utils'
export { getDocFieldsByDomains, translateDomain } from './schemas'
export * from './storage'
export { convertDoc, createTables, getDBClient, retryTxn } from './utils'
export function createPostgreeDestroyAdapter (url: string): WorkspaceDestroyAdapter {
return {
deleteWorkspace: async (ctx, workspace): Promise<void> => {
const client = getDBClient(url)
try {
const connection = await client.getClient()
await ctx.with('delete-workspace', {}, async () => {
// We need to clear information about workspace from all collections in schema
for (const [domain] of Object.entries(domainSchemas)) {
await ctx.with('delete-workspace-domain', {}, async () => {
await retryTxn(connection, async (client) => {
await client`delete from ${connection(domain)} where "workspaceId" = '${connection(workspace.name)}'`
})
})
}
})
} catch (err: any) {
ctx.error('failed to clean workspace data', { err })
} finally {
client.close()
}
}
}
}