Fix model when clone ws (#3395)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2023-06-07 23:46:27 +06:00 committed by GitHub
parent a2463cd69c
commit de1dc72c99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -172,7 +172,13 @@ export abstract class MemDb extends TxProcessor implements Storage {
addDoc (doc: Doc): void {
this.hierarchy.getAncestors(doc._class).forEach((_class) => {
this.getObjectsByClass(_class).push(doc)
const arr = this.getObjectsByClass(_class)
const index = arr.findIndex((p) => p._id === doc._id)
if (index === -1) {
arr.push(doc)
} else {
arr[index] = doc
}
})
this.objectById.set(doc._id, doc)
}

View File

@ -573,6 +573,7 @@ export async function createWorkspace (
if (initWS !== undefined) {
if ((await getWorkspace(db, productId, initWS)) !== null) {
await cloneWorkspace(getTransactor(), getWorkspaceId(initWS, productId), getWorkspaceId(workspace, productId))
await upgradeModel(getTransactor(), getWorkspaceId(workspace, productId), txes, migrationOperation)
}
}
return result