mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-26 19:44:57 +02:00
UBERF-7670: Per region moves (#7444)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user