mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-04 23:04:47 +00:00
Upgrade OOM fix (#2748)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
f989c79c20
commit
ea492902f1
@ -1,4 +1,4 @@
|
|||||||
FROM node:16
|
FROM node:18
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
{ "major": 0, "minor": 6, "patch": 6 }
|
{ "major": 0, "minor": 6, "patch": 73 }
|
||||||
|
@ -37,52 +37,54 @@ async function fillCreatedBy (client: MigrationClient): Promise<void> {
|
|||||||
) {
|
) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
try {
|
while (true) {
|
||||||
const objects = await client.find<Doc>(
|
try {
|
||||||
domain,
|
const objects = await client.find<Doc>(
|
||||||
{ createdBy: { $exists: false } },
|
domain,
|
||||||
{ projection: { _id: 1, modifiedBy: 1 } }
|
{ createdBy: { $exists: false } },
|
||||||
)
|
{ projection: { _id: 1, modifiedBy: 1 }, limit: 10000 }
|
||||||
if (objects.length === 0) {
|
)
|
||||||
continue
|
if (objects.length === 0) {
|
||||||
}
|
break
|
||||||
const txes = await client.find<TxCreateDoc<Doc>>(
|
}
|
||||||
DOMAIN_TX,
|
const txes = await client.find<TxCreateDoc<Doc>>(
|
||||||
{
|
|
||||||
_class: core.class.TxCreateDoc,
|
|
||||||
objectId: { $in: Array.from(objects.map((it) => it._id)) }
|
|
||||||
},
|
|
||||||
{ projection: { _id: 1, modifiedBy: 1, createdBy: 1, objectId: 1 } }
|
|
||||||
)
|
|
||||||
|
|
||||||
const txes2 = (
|
|
||||||
await client.find<TxCollectionCUD<Doc, AttachedDoc>>(
|
|
||||||
DOMAIN_TX,
|
DOMAIN_TX,
|
||||||
{
|
{
|
||||||
_class: core.class.TxCollectionCUD,
|
_class: core.class.TxCreateDoc,
|
||||||
'tx._class': core.class.TxCreateDoc,
|
objectId: { $in: Array.from(objects.map((it) => it._id)) }
|
||||||
'tx.objectId': { $in: Array.from(objects.map((it) => it._id)) }
|
|
||||||
},
|
},
|
||||||
{ projection: { _id: 1, modifiedBy: 1, createdBy: 1, tx: 1 } }
|
{ projection: { _id: 1, modifiedBy: 1, createdBy: 1, objectId: 1 } }
|
||||||
)
|
)
|
||||||
).map((it) => it.tx as unknown as TxCreateDoc<Doc>)
|
|
||||||
|
|
||||||
const txMap = new Map(txes.concat(txes2).map((p) => [p.objectId, p]))
|
const txes2 = (
|
||||||
|
await client.find<TxCollectionCUD<Doc, AttachedDoc>>(
|
||||||
|
DOMAIN_TX,
|
||||||
|
{
|
||||||
|
_class: core.class.TxCollectionCUD,
|
||||||
|
'tx._class': core.class.TxCreateDoc,
|
||||||
|
'tx.objectId': { $in: Array.from(objects.map((it) => it._id)) }
|
||||||
|
},
|
||||||
|
{ projection: { _id: 1, modifiedBy: 1, createdBy: 1, tx: 1 } }
|
||||||
|
)
|
||||||
|
).map((it) => it.tx as unknown as TxCreateDoc<Doc>)
|
||||||
|
|
||||||
console.log('migrateCreateBy', domain, objects.length)
|
const txMap = new Map(txes.concat(txes2).map((p) => [p.objectId, p]))
|
||||||
await client.bulk(
|
|
||||||
domain,
|
console.log('migrateCreateBy', domain, objects.length)
|
||||||
objects.map((it) => {
|
await client.bulk(
|
||||||
const createTx = txMap.get(it._id)
|
domain,
|
||||||
return {
|
objects.map((it) => {
|
||||||
filter: { _id: it._id },
|
const createTx = txMap.get(it._id)
|
||||||
update: {
|
return {
|
||||||
createdBy: createTx?.modifiedBy ?? it.modifiedBy
|
filter: { _id: it._id },
|
||||||
|
update: {
|
||||||
|
createdBy: createTx?.modifiedBy ?? it.modifiedBy
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
})
|
)
|
||||||
)
|
} catch (err) {}
|
||||||
} catch (err) {}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export const coreOperation: MigrateOperation = {
|
export const coreOperation: MigrateOperation = {
|
||||||
|
Loading…
Reference in New Issue
Block a user